Interview Question in SQL Server Security


 

Interview Question :: Sqlexpress connection problem


i'm designing an asp.net web page. i want to connect to a sqlExpress db, but there are errors for user entrance:

'the user is not associated with a trusted sql server connection'

this is my code:
string strCon;
SqlConnection con;
strCon =
"DataSource=.\\SQLEXPRESS;
Integrated Security=False;
Initial Catalog=messages;
User ID=somthing password=somthing";
con = new SqlConnection(strCon);
con.Open();

how can i add a user to SqlExpress server(not sql server). or is the code wrong?
i have searched the web before.
Answers to "Sqlexpress connection problem"
RE: Sqlexpress connection problem?

The problem happens when ur sql express is not installed to use mixed mode authentication.

U have to use the windows uid and pwd to log in



also can u log in sql express using the uid and password that u r suppling from the application?? I feel it will give u the same error



try

Driver={SQL Native Client};

Server=myServerAddress;

Database=myDataBase;

Trusted_Connection=yes;



And for all the connection strings visit

http://www.connectionstrings.com
 
Vote for this answer ::  
RE: Sqlexpress connection problem?

In the DataSource value use .\SQLEXPRESS

single "\" slash

Remove Integrated Security its not required with user id and password.



I think following tutorial will help you for C# code to connect with SQL Database:



http://programming.top54u.com/post/ASP-N...
 
Vote for this answer ::  
Update Alert Setting