try
{
string ConStr = "server=SHADOW-PC\\SQLEXPRESS;database=" + this.textBox1.Text+";uid=sa;pwd=123;";
conn = new SqlConnection(ConStr);
conn.Open();
if (conn.State == ConnectionState.Open)
{
this.label2.Text = "数据库【" + this.textBox1.Text.Trim() + "】已连接并打开。";
}
}
catch
{
MessageBox.Show("数据库连接失败。");
}
这里连接数据库,用的是windows用户验证方式,还是SQL Express验证方式?
或者说是不是只能用SQL Express验证方式?
|