下列ASP.NET语句 ( )正确地创建了一个与SQL Server数据库的连接。
A: SqlConnection conn = new Connection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
B: SqlConnection conn = new SqlConnection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
C: SqlConnection conn = new SqlConnection(Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB)
D: SqlConnection conn = new OleDbConnection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
A: SqlConnection conn = new Connection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
B: SqlConnection conn = new SqlConnection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
C: SqlConnection conn = new SqlConnection(Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB)
D: SqlConnection conn = new OleDbConnection("Data Source = localhost; Integrated Security = SSPI; Initial Catalog = myDB")
举一反三
- 在ADO.NET程序中,某连接字符串如下:“Data Source=DBServer;Initial Catalog=Shop;Integrated Security=SSPI;” 则该连接所引用的数据库名是________。 A: Shop B: SSPI C: DBServer D: Catalog
- 下列ASP.NET语句()正确地创建了一个与SQL Server 2008数据库的连接。 A: str="server=.,uid="zhangsan",pwd="123",database=mydb";SqlConnection con=new SqlConnection; B: str="server=.;uid="zhangsan";pwd="123";database=mydb";SqlConnection con=new SqlConnection; C: str="server=.;uid=zhangsan;pwd=123;database=mydb";SqlConnection con=new SqlConnection; D: str="server=.,uid=zhangsan,pwd=123,database=mydb";SqlConnection con=new SqlConnection;
- 在.NET框架下开发三层结构的数据库应用系统时,using语句范围内定义了一个数据库连接对象,当程序执行到using语句末尾时,将自动释放此数据库对象。假设strSQL为连接字符串,以下using语句使用正确的是( )。 A: using {(SqlConnection conn=new SqlConnection(strSQL)} B: using (SqlConnection conn=new SqlConnection()){strSQL } C: using {}(SqlConnection conn=new SqlConnection(strSQL)) D: using (SqlConnection conn=new SqlConnection(strSQL)){}
- Connection对象的连接字符串保存在ConnectionString属性中,其中用来定义数据库名称的属性是( ) A: Provide B: Data Source或Serve C: Initial Catalog或Database D: Integrated Security或Trusted_Connection
- 在C#中开发ADO.NET应用程序时,使用SqlConnection建立与数据源连接的语句为:[br][/br] SqlConnectioncon = new SqlConnection("Data Source=.\SQL2022;Initial Catalog=test;User ID=xiaozhang;Password=123"); 其中连接字符串中的“test”表示的是( )。 A: 数据库中表的名称 B: 数据库服务器的机器名 C: 数据库的名称 D: 登录数据服务器的账户名