ado.net 连接sql server 2005 如何编写?

2024-11-07 11:24:14
推荐回答(4个)
回答1:

Data Source=.;Initial Catalog=DeNuo;User ID=sa;Password=sa;Connect Timeout=30;
这个就是连接字符串

回答2:

Data source=.\\express; initial catalog=db;integrated security=true

回答3:

server=.;database=数据库名;uid=用户名;pwd=密码

回答4:

SqlConnection objSqlConnection =
new SqlConnection ("server = SQLDB;
uid = sa; pwd = password; database = pubs");
连接数据库
objSqlConnection.Open();
打开数据库连接
SqlCommand objComm=new SqlCommand(sql语句,连接对象);
objComm.CommandType=CommandType.Text ;
建立命令对象