sql server connection problems
-
Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21
-
Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21
-
Hi , I am trying to connect to SQL server through ado.net. When I make the connection using ‘tools ‘ msg shows that test connection succeeded. But when that same connection is used in the code, Error message pops up saying that sql server doesn’t exist or access denied. If anyone can help me in this regard, I’ll be thankful. neoms21
Pls Use this Code C# using System.Data; using System.Data.SqlClient; DataSet ds=new DataSet(); SqlConnection con=new SqlConnection("server=urservername;database=urdatabase;User Id=sa;password=;"); private void Page_Load(object sender, System.EventArgs e) { bind(); } public void bind() { con.Open();//when it needs DataSet ds=new DataSet(); SqlDataAdapter ap=new SqlDataAdapter("select * from region",con); ap.Fill(ds); DataGrid1.DataSource=ds.Tables[0].DefaultView; DataGrid1.DataBind(); }
-
Pls Use this Code C# using System.Data; using System.Data.SqlClient; DataSet ds=new DataSet(); SqlConnection con=new SqlConnection("server=urservername;database=urdatabase;User Id=sa;password=;"); private void Page_Load(object sender, System.EventArgs e) { bind(); } public void bind() { con.Open();//when it needs DataSet ds=new DataSet(); SqlDataAdapter ap=new SqlDataAdapter("select * from region",con); ap.Fill(ds); DataGrid1.DataSource=ds.Tables[0].DefaultView; DataGrid1.DataBind(); }
-
Looks ok to me, exactely what line does it fail on? I would expect connection string problems if it fails on "con.Open()".
i am using the same code but in vb.net (i dont think that makes any diff) yeah it fails exactly on con.open () but whts the problem with connection string i am using pretty much same connection string as in this code. thnkx all for your responses , i except your replies sooner than later neoms21
-
i am using the same code but in vb.net (i dont think that makes any diff) yeah it fails exactly on con.open () but whts the problem with connection string i am using pretty much same connection string as in this code. thnkx all for your responses , i except your replies sooner than later neoms21
-
"pretty much the same" - what does that mean? Have you checked: - server name correct? - database name correct? - username correct? - password correct? - user have the necessary rights on sql server? - can you ping the server?
i mean exactly same everything is correct yes i can ping the server.. infact when i test connection from server explorer it shows test connection succeeded. what are all necessary rights which should be provided so that it can be accessed by any user. thnx :) neoms21