Sql Server connection...
-
30 พฤษภาคม 2549 11:15
I try to connect to SQL Server 2000 but it gives an error: "SQL Server does not exist or access denied."
I created a user wih user id=xyzt and password=abcd in the Query analyzer.I set the authorazation to "SQL Server and Windows". but still I cannot connect....The code is belove:
string conn_str="server=localhost;database=deneme1;user id=xyzt;password=abcd;trusted_connection=false;";
SqlConnection conn=new SqlConnection (conn_str);
try
{
conn.Open();
}
catch (SqlException sql_exc){
MessageBox.Show (sql_exc.Message );
return;}
MessageBox.Show("Connection established");
Thanks in advance.
ตอบทั้งหมด
-
30 พฤษภาคม 2549 11:37
When I use "localhost",it does not connect but when I use "." or the pc name,then it connects...What is the reason?
string conn_str="server=localhost;database=deneme1;user id=xyzt;password=abcd;trusted_connection=false;"; //-->fails
string conn_str="server= . ;database=deneme1;user id=xyzt;password=abcd;trusted_connection=false;"; //-->it's ok
-
30 พฤษภาคม 2549 13:30ผู้ดูแล
Hi,
localhost uses TCP/IP which might not be enabled in your case.
HTH, Jens Suessmeyer.
---
http://www.sqlserver2005.de
---