PrepAway - Latest Free Exam Questions & Answers

Which code segment should you add at line 03?

You are creating a Windows application for a financial services provider by using the .NET
Framework 3.5.You write the following code segment in the form. (Line numbers are
included for reference only.)
01 string queryString =
02 “SELECT CategoryID, CategoryName FROM Categories”;
03
The connection string for the financial services database is stored in the variable named
connString.You need to ensure that the form populates a DataGridView control named
gridCAT. Which code segment should you add at line 03?

PrepAway - Latest Free Exam Questions & Answers

A.
OleDbDataAdapter adapter = new OleDbDataAdapter(queryString, connString);
DataSet categories = new DataSet();
adapter.Fill(categories, “Categories”);
gridCAT.DataSource = categories.Tables[0];

B.
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
OleDbCommand cmd = new OleDbCommand(queryString, conn);
OleDbDataReader reader = cmd.ExecuteReader();
gridCAT.DataSource = reader;

C.
OleDbDataAdapter adapter = new OleDbDataAdapter(queryString, connString);
DataSet categories = new DataSet();
adapter.Fill(categories, “Categories”);
gridCAT.DataSource = categories;

D.
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
OleDbCommand cmd = new OleDbCommand(queryString, conn);
OleDbDataReader reader = cmd.ExecuteReader();
gridCAT.DataSource = reader.Read();


Leave a Reply