How to create a SqlDataAdapter in ADO.Net?

How to create a SqlDataAdapter in ADO.Net?

SqlDataAdapter holds the SQL commands and connection object for reading and writing data.  It initializes with a SQL select statement and connection object:
SqlDataAdapter daStudent = new SqlDataAdapter(
    "select StudentID, CollegeName from Students", conn);
The SQL select statement specifies what data will be read into a DataSet.   
The connection object, conn, should have already been instantiated, but not opened. 
SqlCommandBuilder is instantiated with a single constructor parameter of the SqlDataAdapter, daStudent, instance.
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daStudent);
SqlCommandBuilder will read the SQL select statement (specified when the SqlDataAdapter was instantiated), infer the insert, update, and delete commands.

Date:2028-10-10 00:00:00

Post Your Answers

User Email:

User Name:

Related ADO.NET Subjective Links

ADO.NET Subjective interview questions and answers for experienced and fresher