PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. The
application connects to a Microsoft SQL Server database. You use the following SQL statement to
retrieve an instance of a DataSet object named ds.
SELECT CustomerID, CompanyName, ContactName, Address, City
FROM dbo.Customers
You need to query the DataSet object to retrieve only the rows where the ContactName field is not
NULL. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
from row in ds.Tables(0).AsEnumerable()
where DirectCast(row(“ContactName”), String) IsNot Nothing

select row

B.
from row in ds.Tables(0).AsEnumerable()
where row.Field(Of String)(“ContactName”) IsNot Nothing
select row

C.
from row in ds.Tables(0).AsEnumerable()
where Not row.IsNull(DirectCast(row(“ContactName”), String))
select row

D.
from row in ds.Tables(0).AsEnumerable()
where Not Convert.IsDBNull(row.Field(Of String)(“Region”))
select row

Explanation:
Field<T>(DataRow, String) Provides strongly-typed access to each of the column values in the
specified row.
The Field method also supports nullable types.


Leave a Reply