You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The application uses the following LINQ query.
var query = from o in orderLinesQuery
where (string)o["CarrierTrackingNumber"] == "AEB6-4356-80"
select new
{
SalesOrderID = o.Field("SalesOrderID"),
OrderDate = o.Field("OrderDate")
};
The CarrierTrackingNumber field in the DataRow is nullable. You need to ensure that an exception does not occur if the CarrierTrackingNumber field has a null value.
Which code segment should you use?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET.
The connection string that contains the user name and password is stored directly in the code of the application.
You need to ensure that the password in the connection string is as secure as possible.
What should you do?
You create an application by using the Microsoft .NET Framework 3.5 and Microsoft ADO.NET. The application connects to a Microsoft SQL Server 2005 database.
The database contains two tables that are displayed in two different GridView controls. The tables are displayed by using two SqlConnection objects.
You need to display the tables simultaneously by using a single SqlConnection object.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. The application caches refer to tables by using a Local Database Cache class. You have completed the following code segment. (Line numbers are for reference only.)
01 public partial class LocalDataCacheProvider
02 {
03 private void InitializeConnection(string connectionString)
04 {
05 this.Connection = new System.Data.SqlClient.SqlConnection(connectionString);
06 }
07 private void InitializeNewAnchorCommand()
08 {
09
10 }
11 }
You want to make sure that the LocalDataCacheProvider class handles all database communication.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You have completed the following code segment in the exception handler of the application. (Line numbers are for reference only.)
01 private string ShowSQLErrors(SqlException ex){
02 StringBuilder sb = new StringBuilder();
03 foreach (SqlError err in ex.Errors) {
04 sb.Append("Message: ");
05 sb.Append(err.Number.ToString());
06 sb.Append(", Level: ");
07
08 sb.Append(", State: ");
09 sb.Append(err.State.ToString());
10 sb.Append(", Source: ");
11 sb.AppendLine(err.Source.ToString());
12 sb.AppendLine(err.Message.ToString());
13 sb.AppendLine();
14 }
15 return sb.ToString();
16 }
You need to make an insertion on line 07 so that the original severity level of the error is included in the error message for each SQL error that occurs.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. You have completed the following code segment. (Line numbers are for reference only.)
DataTable tbl = new DataTable();
tbl.Columns.Add("Price", typeof(double));
//Other columns added
//Fill data
You need to retrieve the maximum value in the Price column of the tbl DataTable.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. Your application contains the following code. The Customer and Invoice tables are found in the invoice records of customers that reside in the database. Your application contains the following code.
DataSet ds = new DataSet();
DataTable tblCust = ds.Tables.Add("Customer");
DataTable tblInv = ds.Tables.Add("Invoice");
DataColumn colPar = tblCust.Columns.Add("ID", typeof(int));
tblCust.Constraints.Add("PKey", colPar, true);
tblInv.Columns.Add("InvNo", typeof(string));
DataColumn colChild = tblInv.Columns.Add("CustomerID", typeof(int));
DataRow[] relatedRows;
//Retrieve data for Customer and Invoice
You need to retrieve the invoice details from the tblInv DataTable for customer records that have a value 1 in the ID column of the tblCust DataTable.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application that will connect to the Microsoft SQL Server 2005 database. Your application contains the following code.
string sql = "Select InvoiceNo, OrderAmount from Orders";
SqlDataAdapter adp = new SqlDataAdapter(sql, con);
DataTable tblOrders = new DataTable();
adp.Fill(tblOrders);
You want the following: If the value of the OrderAmount column is greater than 1500, then a discount of 6 percent is calculated. Furthermore, you need to create a DataColumn object named Discount that contains the
discount value for each row in the tblOrders DataTable.
What should you do?
You work as an application developer at Contoso.com. You use Microsoft .NET Framework 3.5 and Microsoft
ADO.NET to develop an application. The application uses the Microsoft OLE DB Provider as the data provider for Oracle. The application throws an error when you try to retrieve the Oracle BLOB data. You need to make
sure that the Oracle BLOB data can be retrieved.
What should you do?