Monday, November 24, 2008

Consuming .net webservices with Jquery in JASON format.

1) Add [ScriptService] attribute to your webservice.

2) Call your method with JQuery. Very Simple!

$.ajax({
type: "POST",
url: "ServiceName.asmx/WebMethodName",
data: "{'parameter1':'p1','parameter2':'p2'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do
 stuff
}
});

Technorati Tags: ,,,,

Thursday, November 6, 2008

SQL Server: Peer-to-Peer Transactional Replication

It is often necessary to have the same database running in multiple servers. With transactional replication, several instances of the same database can run in completely different servers and communicate to each other. All the insert, update, delete operations are synced between the databases.

An application can benefit from peer-to-peer replication in the following ways:

    • Improved read performance, because reads are spread out over two or more servers.
    • Higher availability if maintenance is required or in case of failure at one server.

Read More:
http://msdn.microsoft.com/en-us/library/ms151196.aspx

Cool!, So how can I configure this? Here is the link:

Configuration with SQL Management Studio

 

Tuesday, November 4, 2008

Resize Bitmap C#

public Bitmap ResizeBitmap(Bitmap b, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage((Image)result))
g.DrawImage(b, 0, 0, width, height);

return result;
}

Resetting the identity number in SQL Server.

DBCC CHECKIDENT ('tablename', RESEED,1)

Thursday, August 16, 2007

USE Database
SELECT ColumnName
FROM Table
Group BY ColumnName
Having count(*) > 1

Monday, August 6, 2007

Copy a table from one database to another

There are many ways to copy a database table to an another database. Below you will find the simplest solution I found for myself.

SELECT *
INTO TargetDatabase.dbo.MyTable
FROM SourceDatabase.dbo.MyTable

del.icio.us Tags: ,,

Thursday, July 19, 2007

ASP GridView: Displaying the Summary Data in the Footer

It is many times necessary to display some additional data in the GridView's footer row. This task can be accomplished through the RowDataBound event handler.

protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
         if (e.Row.RowType == DataControlRowType.Footer) //if the row is footer
         {
                e.Row.Cells[3].Text = "Some text" ;
         }
}

del.icio.us Tags: ,,,

Tuesday, May 15, 2007

identity ID of the inserted row with TableAdapter.Insert()

Simple solution:

Select MAX(xxxID) From xxxTable

SOAP Request XML with User Credentials

private string SAR(XmlDocument requestXML, string webServiceName)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(webServiceBasePath + webServiceName);
request.Headers.Add("SOAPAction", webServiceBasePath + webServiceName);
request.Credentials = new NetworkCredential(kulAdi, kulSif);
request.ContentType = "text/xml";
request.Method = "POST";
request.Accept = "text/xml";
Stream stm = request.GetRequestStream();
stm.Write(System.Text.Encoding.ASCII.GetBytes(requestXML.InnerXml.ToString()), 0, requestXML.InnerXml.ToString().Length);
stm.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader r = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
return r.ReadToEnd();
}

Monday, May 14, 2007

ie6 ie7 CSS min-height problem

Different Internet explorer versions interpret CSS differently. One of the common problem is to set a minimum height for a tag or div section. Just setting up min-height property will not be enough because of the fact that ie6 does not have a support. Below you will find very simple workaround for the problem.

Solution:
min-height:600px;
height: auto;
height: 600px;

Now it works for both browsers.