我得到了这个例外:
例外:
无法打开数据库" FingerPR"登录请求。登录失败。用户' NR-PC \ NR'
登录失败我的连接字符串是
key="conn" value="Data Source=NR-PC\SQLEXPRESS;Initial Catalog=FingerPR;Integrated Security=True"
c#:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
SqlConnection con1 = new SqlConnection(constring);
SqlDataAdapter dsa = new SqlDataAdapter("Select cname,encrypt,fp,sip,fpath,id from msg", con1);
DataSet ds = new DataSet();
BindingSource bsourse = new BindingSource();
SqlCommandBuilder cmd = new SqlCommandBuilder(dsa);
dsa.Fill(ds, "msg");
bsourse.DataSource = ds.Tables["msg"];
dataGridView1.DataSource = bsourse;
groupBox1.Visible = true;
groupBox2.Visible = true;
label1.Visible = true;
dataGridView1.Visible = true;
con1.Close();
}
答案 0 :(得分:0)
您是否为用户NR-PC\NR
授予了对数据库的访问权限?您可以使用SSMS使用该用户访问数据库吗?如果没有将用户添加到具有适当权限的数据库......