Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlConnection error

Status
Not open for further replies.

moron3

Technical User
Dec 2, 2008
17
US

When I use the Visual Studio 2010 Datasource designer to connect to my SQL server remotely everything works fine. However, if I try to connect programatically from the same project using this code (sensitive info X'd out):

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=\"XX.XXX.XXX.XXX, 1433\";User ID=ASPNET;Password=XXXXXXXX";
conn.Open();

I get the following error:

{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The requested service provider could not be loaded or initialized.)"}

port 1433 is open on the remote network and like I said I can browse the server fine through datasource designer. I'm using the same connection string as the designer in my code.
 
the little bit you have here is correct. either there is a problem with the connection string, or the database is not configured to allow this type of connection.

google the error message and you will get plethora information which should help you debug the problem.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top