Data Set is a connection-less service and Data reader is a connection oriented service. Dataset is used to store the data, it contains collections of Datatable. Datareader is used to connect to the database for retrieving data. Data Reader – Forward only where as Dataset – Can loop through dataset…. Continue reading
OleDbConnection con = new OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0; Data Source= c:/file.xls; Extended Properties=Excel 8.0; “); OleDbDataAdapter oadp1 = new OleDbDataAdapter(“Select * from [sheet1$] where Id >0”, con); DataSet ods1 = new DataSet(); oadp1.Fill(ods1, “Data”); DataSet Dds1 = new DataSet(); Dds1.Tables.Add(new DataTable(“NewData”)); Dds1.Tables[“NewData”].Columns.Add(new DataColumn(“Id”)); Dds1.Tables[“NewData”].Columns.Add(new DataColumn(“Name”)); for (int i = 0; i < ods1.Tables[“Data”].Rows.Count;… Continue reading
ExecuteNonQuery() – only insert, update, delete. ExecuteScaler() – only select with output of sum(), count(), etc. give only one value. ExecuteReader() – Select command, read only, forward only.
The System.Data namespace consists mostly of the classes that constitute the ADO.NET architecture. The ADO.NET architecture enables you to build components that efficiently manage data from multiple data sources. In a disconnected scenario (such as the Internet), ADO.NET provides the tools to request, update, and reconcile data in multiple tier… Continue reading
SqlConnection con=new SqlConnection (ConfigurationSettings.AppSettings[“cons”]); SqlCommand cmd=new SqlCommand(“student”,con); SqlDataAdapter db=new SqlDataAdapter(); db.SelectCommand=cmd; cmd.CommandType=CommandType.StoredProcedure; DataSet ds = new DataSet(); db.Fill(ds,5,15,”student”); DataGrid1.DataSource=ds; DataGrid1.DataBind(); this will return the 10 rows of the result set. In the above code “student” is the name of the stored procedure.
DataSet is an ADO.Net object and RecordSet is an ADO object. DataSet can be considered as a logical database as it has the capability to store more than one table and have relations maintained between the tables as in a relational database. Where as a RecordSet can hold only one… Continue reading
ExecuteReader : Use for accessing data. It provides a forward-only, read-only, connected record-set. ExecuteNonQuery : Use for data manipulation, such as Insert, Update, Delete. ExecuteScalar : Use for retrieving 1 row 1 col. value., i.e. Single value. eg: for retrieving aggregate function. It is faster than other ways of retrieving… Continue reading
In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset. There are important differences between them. A recordset looks like a single table. If a recordset is to contain data from multiple database tables, it must use a JOIN query, which assembles the data… Continue reading
ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.
Pros ADO.NET is rich with plenty of features that are bound to impress even the most skeptical of programmers. If this weren’t the case, Microsoft wouldn’t even be able to get anyone to use the Beta. What we’ve done here is come up with a short list of some of… Continue reading