Rene Nielsen

Rene Nielsen

  • NA
  • 22
  • 31.2k

Cannot open database "GADatabase". The login failed. HELP!

Dec 7 2010 8:17 AM

Cannot open database "GADatabase" requested by the login. The login failed. HELP!


Hey, i are in the makings of a program C# at my school, and i have a Databae in SQL Server management studios called GADatabase
I have my database class like this
  1. public class Database  
  2. {  
  3.     private static SqlCommand ObjCmd;  
  4.     static string SqlConn = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=GADatabase;Integrated Security=SSPI;";  
  5.     private static SqlConnection ObjConn = new SqlConnection(SqlConn);  
  6.   
  7.     public Database()  
  8.     {  
  9.     }  
  10.   
  11.     public void AddStudent(Student Student)  
  12.     {  
  13.         ObjConn.Open();  
  14.         ObjCmd = ObjConn.CreateCommand();  
  15.         ObjCmd.CommandType = System.Data.CommandType.Text;  
  16.         int i = 0;  
  17.         try  
  18.         {  
  19.             ObjCmd.CommandText = string.Concat(Student.InsertSqlQuery);  
  20.             i = ObjCmd.ExecuteNonQuery();  
  21.   
  22.         }  
  23.         catch{ }  
  24.           
  25.         ObjConn.Close();  
  26.     }  
  27. }  
  
but if i call the AddStudent and try to acces the ObjConn.Open(); it just returns and gives me the error "Cannot open database "GADatabase" requested by the login. The login failed."
Please if anyone can help me with this error :)
and feel free to ask for more information if that is what u need to help me with my problem

Answers (7)