Which code segment should you add at line 02?

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 = "SELECT CategoryID, CategoryName FROM Categories";
02

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 02?

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 = "SELECT CategoryID, CategoryName FROM Categories";
02

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 02?

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();g
ridCAT.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 0

Your email address will not be published. Required fields are marked *