无法打开登录请求的数据库“FingerPR”。登录失败。用户'NR-PC \ NR'登录失败

时间:2014-04-18 07:32:47

标签: c# sql visual-studio-2010 sql-server-2008

我得到了这个例外:

例外:

无法打开数据库" 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();       
}

1 个答案:

答案 0 :(得分:0)

您是否为用户NR-PC\NR授予了对数据库的访问权限?您可以使用SSMS使用该用户访问数据库吗?如果没有将用户添加到具有适当权限的数据库......