单项选择题

A. Set the database driver name in the connection string of the application, and then the connection object as follows: DbConnection connection = new OdbcConnection(connectionString);
B. Create the connection object as follows: DbProviderFactory factoryDbProviderFactories.GetFactory(databaseProviderName); DbConnection connection =factory.CreateConnection();
C. Create the connection object as follows: DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.Odbc"); DbConnection connection = factory.CreateConnection();
D. Set the database driver name in the connection string of the application, and then the connection object as follows:DbConnection connection = new OleDbConnection(connectionString);

相关考题

单项选择题 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 database on the Microsoft SQL Server 2005 database has two tables that are displayed by using two SqlConnection objects in two different GridView controls. You want the tables to be displayed at the same time with the use 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. You have completed the following code segment. (Line numbers are for reference only.)   01 private void GetRecords(SqlDataAdapter da, DataTable table) {  02  03     try {  04         da.Fill(table);  05     }  06     catch (SqlException exp) {  08     }  09     finally {  10  11     }  12 }  13  You have set the da.SelectCommand.CommandText property to a stored procedure, which declares a variable named @msg. If the stored procedure has a bad shipping address, it will do the following:   1. sets @msg with the id of the record.  2. raises an error for the record.   The raised error can be seen in the following text: RaiseError(@msg, 10,  1). You want to retrieve all records, valid or not; and that a list item is added to the lstResults list box for each invalid record.   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 application has a connection string that is defined as follows:   "Server=DB01;Database=Products Security=SSPI; Asynchronous Processing=true"   Your application contains the following code. (Line numbers are for reference only.)   01 protected void UpdateData(SqlCommand cmd)  02 {  03 cmd.Connection.Open();  04  05 lblResult.Text = "Updating ...";  06 }   The cmd object takes forever to execute. You want to make sure that the application continues to execute while cmd is executing.   What should you do?()