Microsoft
70-516 · Question #251
You have a database named DB1 that contains a table named Customers. You declare a DataSet named customersDataSet. You need to ensure that customersDataSet contains all of the records from the…
The correct answer is C. Option C. use the New SqlCommand - Example: To create a sample Visual C# .NET console application that demonstrates how to use the SqlCommandBuilder object to automatically generate the DeleteCommand, the InsertCommand, and the UpdateCommand properties of the SqlCommand object for a…
Implementing Data Access
Question
You have a database named DB1 that contains a table named Customers. You declare a DataSet named customersDataSet. You need to ensure that customersDataSet contains all of the records from the Customers table. Which code should you use?
Exhibit
Options
- AOption A
- BOption B
- COption C
- DOption D
How the community answered
(42 responses)- A7% (3)
- B5% (2)
- C71% (30)
- D17% (7)
Explanation
- use the New SqlCommand - Example: To create a sample Visual C# .NET console application that demonstrates how to use the SqlCommandBuilder object to automatically generate the DeleteCommand, the InsertCommand, and the UpdateCommand properties of the SqlCommand object for a SqlDataAdapter object. SqlConnection cn = new SqlConnection(); DataSet CustomersDataSet = new DataSet(); SqlDataAdapter da; SqlCommandBuilder cmdBuilder; //Set the connection string of the SqlConnection object to connect //to the SQL Server database in which you created the sample cn.ConnectionString = "Server=server;Database=northwind;UID=login;PWD=password;"; //Initialize the SqlDataAdapter object by specifying a Select command //that retrieves data from the sample table. da = new SqlDataAdapter("select * from CustTest order by CustId", cn); //Initialize the SqlCommandBuilder object to automatically generate and initialize //the UpdateCommand, InsertCommand, and DeleteCommand properties of the SqlDataAdapter. cmdBuilder = new SqlCommandBuilder(da); //Populate the DataSet by running the Fill method of the SqlDataAdapter. da.Fill(CustomersDataSet, "Customers");
Topics
#DataSet#SqlDataAdapter#Fill method#database connection
Community Discussion
No community discussion yet for this question.
