Help Trying Connect to SQL
-
Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();
-
Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();
-
Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();
Does the user your process is running as (ASPNET probably) have permission to log on to the database. By default the answer is no. You must add a login to SQL Server to accept the user you are connecting as. You must also add that user to the database on the server you want to connect to. You have not specified a user in your connection string so I'm guessing that it will just default to trying to use a trusted connection (the error message hints at this also). ASP.NET applications connect using a special locked down account (for security). That account is generally ASPNET, although on some operating systems it will use another account (Win Srv 2003 will use NT AUTHORITY\NETWORK SERVICE)
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
Does the user your process is running as (ASPNET probably) have permission to log on to the database. By default the answer is no. You must add a login to SQL Server to accept the user you are connecting as. You must also add that user to the database on the server you want to connect to. You have not specified a user in your connection string so I'm guessing that it will just default to trying to use a trusted connection (the error message hints at this also). ASP.NET applications connect using a special locked down account (for security). That account is generally ASPNET, although on some operating systems it will use another account (Win Srv 2003 will use NT AUTHORITY\NETWORK SERVICE)
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
If you are using Windows Authentication then you do not pass a user name and password.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
im using Authentication: Windows Authentication, so i did not entered username or password , for this reasone i did not specified a user in my conection string, i dont know if i have to put a user , if yes i have to then what is my user will be ? thanks
You might find this article useful: How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
Im new in SQL, im trying to connect to sql data base but it give me exception-->(Login failed for user ''. The user is not associated with a trusted SQL Server connection.) i think there is wrong with SqlConnection parameter, so what is the wrong? im with sql express 2005 & vs2005 SqlConnection SQLConn; SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; " ); SQLConn.Open();
the connection string should include "Integrated Security=SSPI". that is
SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; Integrated Security=SSPI " );
hope this will help you. Cheers Ramesh.Kanjinghat -
the connection string should include "Integrated Security=SSPI". that is
SQLConn = new SqlConnection( " Data Source = .\\SQLEXPRESS;" + " Initial Catalog = MTDB; Integrated Security=SSPI " );
hope this will help you. Cheers Ramesh.Kanjinghat