1

I am getting this exception:

Exception :

Cannot open database "FingerPR" requested by the login. The login failed. Login failed for user 'NR-PC\NR'

my connection string is

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();       
}
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
user2394030
  • 41
  • 1
  • 4
  • 2
    Did you care to read the error? It's pretty self-explanatory... – ivan_pozdeev Apr 18 '14 at 07:40
  • possible duplicate of [Cannot open database "test" requested by the login. The login failed. Login failed for user 'xyz\ASPNET'](http://stackoverflow.com/questions/2575907/cannot-open-database-test-requested-by-the-login-the-login-failed-login-fail) – Alberto Solano Apr 18 '14 at 07:56

1 Answers1

0

Did you grant access to the DB for the user NR-PC\NR? Can you access the DB using that user with SSMS? If not add the user to the DB with the appropriate rights...

Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
  • i can access db using ssms windows authentication with user NR-PC – user2394030 Apr 18 '14 at 07:46
  • Is that the same user? if the app is running in IIS it may use a different user, so SSMS works with your user, but the App-Pool user can't access. Did you check or try to set explicit rights for `NR-PC\NR`? – Christoph Fink Apr 18 '14 at 07:48
  • yes ,user is same. i have tried in security >> NR-PC\NR>> and checked for database FingerPR.also in database properties i have checked grant for all – user2394030 Apr 18 '14 at 08:02
  • `NR-PC` (effectively `NR-PC\NR-PC`) and `NR-PC\NR` aren't the same user. – ivan_pozdeev Apr 18 '14 at 11:12
  • thank u all. i was loging to SSMS with user NR-PC . loging as NR-PC\SQLEXPRESS solved my issue – user2394030 Apr 18 '14 at 11:50