Sunday, February 12, 2012

Connecting to SQL Server via a Lan Connection

Hi, I have developed a windows form application which connects to a sql server 2k database via the following conneciton string:

Private con As New SqlConnection("Data Source=(local);trusted_connection=true;Initial Catalog=Database1")

This works fine for running locally but I need to give my Windows form application to other users on the lan and have them reach my database server. So next I tried:

Private con As New SqlConnection("WorkStation ID= E134017.nw.nos.Boeing.com;Data Source=(local);trusted_connection=true;Initial Catalog=Database1")

where E134017.nw.nos.boeing.com is the full network path to my computer

It does not work and results in "Server does not exist or access is denied"

I next went in SQL and turned on tcp/ip and still no luck.

Any ideas,

Fred

Hi Fred
I think you have to change your Data source in the connection string to the Server Name (PC Name that the SQL server is installed on)
i.e.
Private con As New SqlConnection("Data Source=FredPC;trusted_connection=true;Initial Catalog=Database1")

No comments:

Post a Comment