Tuesday, May 5, 2009
Explain DataView
It provides a means to filter and sort data within a data table.
Example:
DataView myDataView = new DataView(myDataSet.Tables["Customers"]);
// Sort the view based on the FirstName column
myDataView.Sort = "CustomerID";
// Filter the dataview to only show customers with the CustomerID of XYZ
myDataView.RowFilter = "CustomerID=XYZ";
Friday, May 1, 2009
Difference between ExecuteNonQuery, ExecuteScaler, ExecuteReader
Difference Angle | ExecuteNonQuery | ExecuteScaler | ExecuteReader |
About | After Executing Sql statement Returns number of rows affected | Returns Single value, Executes first column first row only | Send the Command text to connection and builds a SqlDataReader. |
When we use | ExecuteNonQuery is used to perform Catalog operation like Creating table in database or Changing of data in tables (without using Dataset) by using Insert, Update, Delete, create | Selecting only single fields like count field | When we manipulating with DataReader it used, Sending SQL Select statements to a database, Invoking Stored Procedures |
Example | Example: | Example : select count(*) from emp | Example: |