saifullah khan

saifullah khan

  • NA
  • 335
  • 295.2k

Cannot open database "E_learning" requested by the login. The login failed.

Oct 26 2011 5:40 AM
i have created an application that takes a file and save it into database. here is the code
 
int len = FileUpload1.PostedFile.ContentLength;
            byte[] pic = new byte[len];
            FileUpload1.PostedFile.InputStream.Read(pic, 0, len);
            cnn.Open();
            cmd = new SqlCommand("insert into images values='" + pic + "'", cnn);
            cmd.ExecuteNonQuery();
but when i click on upload it gives me the following error
Cannot open database "E_learning" requested by the login. The login failed.
 
i knw it is due to i have not used the uid and pwd options in db connection string. actually i am using the windows authentication mode in sql server. there is no user created for login through sql authentication mode. although i have created one. but i doesnt work. can somebody solve my problem?

Answers (1)