Pages

More on DataTable in ADO.Net 2.0

The DataTable's CreateDataReader method creates an instance of DataTable Reader. When a DataTableReader is created from a DataSet or a DataTable's CreateDataReader method, the DataTableReader will contain all of the rows from the container object, with the exception of deleted rows.
The DataTableReader is a lighter weight object than the DataTable and, unlike the DataReader (SqlDataReader), the DataTableReader is disconnected. This is a great feature because you get the lightweight object that you can iterate through quickly (like the DataReader) and it is disconnected from any data source (unlike the DataReader). A DataTableReader can be thought of as an iterator over the underlying table's rows, similar to a foreach enumeration of the contents of the table.Keep in mind that the DataTableReader only moves forward.
The following example shows how you can create a DataTableReader.
using (SqlConnection cn = new SqlConnection(cnStr))
{
SqlCommand cmd = new SqlCommand(sqlAllCustomers, cn);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
DataTable dtCustomers = new DataTable("Customers");
adpt.Fill(dtCustomers);
DataTableReader dtRdr = ds.CreateDataReader();
dgvCustomers.DataSource = dtRdr;
}

Loading multiple Table's in DataTableReader is similar to the retriving multiple resultset. the method NextResult can be used to move to other table's records.
DataTableReader dtRdr = dt1.CreateDataReader();
DataTable dt2 = new DataTable();
dt2.Load(dtRdr);

Like Dataset Merge, Two Tables can be merged together by the method Merge of DataTable.
dtTableOne.Merge(dtTableTwo);

Similar to DataSet, DataTable can be written as XML by the WriteXml method. the DataTable in ADO.NET 2.0 also exposes the ReadXml, ReadXmlSchema, and WriteXmlSchema methods.
The DataSet also has some new methods and properties. In fact, both the DataSet and the DataTable now expose the RemotingFormat property as well as the Load and CreateDataReader methods. The RemotingFormat property is used to indicate whether to serialize the DataTable or DataSet in binary or XML format.

Ajax Scipt Method returns XML Formatted result.

The ResponseFormat attribute of script method in ASP.NET AJAX’s ScriptMethod is used to return result in XML Format.

[ScriptMethod (ResponseFormat=ResponseFormat.Xml)]
public XmlDocument GetData()
{
...
}

GridView Control No Data Message

The GridView control supports the EmptyDataTemplate property for you to specify the markup that should be used when the control is bound to an empty data source. Don't forget to write the Databind code in the code behind page. if the binded object [DataSet or DataTable or ICollection] is empty, then this empty template will be displayed.

<asp:GridView ...>
...
<EmptyDataTemplate>
<table style="border:solid 1px black"><tr><td>
<b>GridView Control No Data Message</b>
No data to display. </td>
</tr></table>
</EmptyDataTemplate>
</asp:GridView>

T-SQL Statement SET NOCOUNT ON

This one line of code, put at the top of a stored procedure turns off the messages that SQL Server sends back to the client after each T-SQL statement is executed. This is performed for all SELECT, INSERT, UPDATE, and DELETE statements. Having this information is handy when you run a T-SQL statement in a query window, but when stored procedures are run there is no need for this information to be passed back to the client.
By removing this extra overhead from the network it can greatly improve overall performance for your database and application.
If you still need to get the number of rows affected by the T-SQL statement that is executing you can still use the @@ROWCOUNT option. By issuing a SET NOCOUNT ON this function (@@ROWCOUNT) still works and can still be used in your stored procedures to identify how many rows were affected by the statement.
Microsoft even realized the issue that this creates and has changed the stored procedure templates from SQL Server 2000 to SQL Server 2005.


courtesy : - MSSQLTips.com