nerdexam
Microsoft

70-516 · Question #95

70-516 Question #95: Real Exam Question with Answer & Explanation

The correct answer is A. var dt = new taStore.ProductDataTable();. DataRowCollection.Find() Method To use the Find method, the DataTable object to which the DataRowCollection object belongs to must have at least one column designated as a primary key column. See the PrimaryKey property for details on creating a PrimaryKey column, or an array of

Question

You use Microsoft .NET Framework 4.0 to develop an application that connects to a Microsoft SQL Server 2008 database. The application includes a table adapter named taStore, which has the following DataTable. There is a row in the database that has a ProductID of 680. You need to change the Name column in the row to "New Product Name". Which code segment should you use?

Options

  • Avar dt = new taStore.ProductDataTable();
  • Bvar ta = new taStoreTableAdapters.ProductTableAdapter();
  • Cvar dt = new taStore.ProductDataTable();
  • Dvar dt = new taStore.ProductDataTable();

Explanation

DataRowCollection.Find() Method To use the Find method, the DataTable object to which the DataRowCollection object belongs to must have at least one column designated as a primary key column. See the PrimaryKey property for details on creating a PrimaryKey column, or an array of DataColumn objects when the table has more than one primary key. var dt = new CustomersDS.CustomersDataTable(); var ta = new CustomersDSTableAdapters.CustomersTableAdapter(); CustomersDS.CustomersRow row = (CustomersDS.CustomersRow)dt.Rows.Find(4); row.Name = "A. Found Customer Id"; DataTable.Select() Method Gets an array of all DataRow objects that match the filter criteria. To create the filterExpression argument, use the same rules that apply to the DataColumn class's Expression property value for creating filters. var ta = new CustomersDSTableAdapters.CustomersTableAdapter(); var dt = ta.GetData(); var row = dt.Select("CustomerID > 2"); row[0]["Name"] = "B. Found Customer Id"; TableAdapter Overview

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice