Trouble connecting to SQL Server with ASP.NET web application
-
Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code:
protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close();
I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RC -
Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code:
protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close();
I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RCTry adding:
Trusted_Connection=false;
to your connection string.
// Steve McLenithan
Cluelessnes:
There are no stupid questions, but there are a lot of inquisitive idiots. -
Try adding:
Trusted_Connection=false;
to your connection string.
// Steve McLenithan
Cluelessnes:
There are no stupid questions, but there are a lot of inquisitive idiots.I tried "Trusted_Connection=false" and got the same error. But thanks for the suggestion.
-
Hello, I am attempting to retrieve data from a database on a SQL server. This data will them be displayed on my web page. For some reason, everytime I attempt to view the web page, I get the following error: "SQL Server does not exist or access denied." I am positive that my machine has access to the server and that the user name and password are correct. I have tested this several times through Enterprise Manager and through the "Connect To Database" option in Visual Studio. It just doesn't work through the web application. Here is part of my code:
protected System.Data.SqlClient.SqlConnection sqlserver; sqlserver.ConnectionString = "Data Source=12.34.56.78; User ID=sa; password=*****; Initial Catalog=Global; Integrated Security=false"; sqlserver.Open(); // the code to fill the dataset goes here sqlserver.Close();
I have attempted to connected to several different servers, which I know I have access to, but I keep getting the same error. This is not happening to anyone else with access. Is there a setting on my machine that is making this happen? Any ideas would be much appreciated. Thanks for your help, RCYes u will get this type of problem if ur SQL server is not running , but as u said that its running then we dont have to bother about that I did the same thing but I did not face any problem. Try using this connectivity approach. conn = New SqlConnection("data source=.;initial catalog = d/b name;integrated security=SSPI;persist security info=False;workstation id=" + System.Net.Dns.GetHostName + ";packet size=4096") comm = New SqlCommand("Select * from table_name") Conn.Open() Comm.Connection = Conn Reader = Comm.ExecuteReader While Reader.Read DropDownList1.Items.Add(reader.GetValue(0).ToString) End While