Friday, September 6, 2013

Cannot open SQL Server 2008 database in Visual Studio 2008

Cannot open SQL Server 2008 database in Visual Studio 2008

I am using Visual Studio 2008 with SQL Server 2008. Whenever I am trying
to connect to database I get an error. I am using c# language. As I am new
to .net development I can not understand what to do. Please help me to get
rid of this. Thanks in advance.
Here is the code:
string str, constr;
Boolean inc = false;
SqlDataReader dr;
constr = "Server = JITSEKHAR-PC ; Database = Hospitaldata ; user id = ;
password = ; Integrated Security = True";
SqlConnection con = new SqlConnection(constr);
con.Open();
Here is the complete error:
System.Data.SqlClient.SqlException was unhandled
Message="Cannot open database \"Hospitaldata\" requested by the login. The
login failed.
Login failed for user 'Jitsekhar-PC\Jitsekhar'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=11
LineNumber=65536
Number=4060
Procedure=""
Server="JITSEKHAR-PC"
State=1

No comments:

Post a Comment