Reputation: 139
I'm building a school project application that has a connection to a SQL Server database.
On my computer, the program works flawlessly, however, when I built it and send it to another computer for testing, I'm getting an unhandled exception that I can only assume is the connection not being successful.
I'm using an app.config, with the connection string as follows:
<connectionStrings>
<add name="TEAMSConnectionString"
connectionString="Data Source=.\MYSQL;Initial Catalog=TEAMS;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Can someone help me write a connection string that should work on all computers?
Upvotes: 0
Views: 554
Reputation: 13945
connectionString="Data Source=.\MYSQL
It looks like your database is located on your local machine. That's what the .
means in the connection string. It's short for localhost
. So it doesn't work on the other computer because it is looking for the database on its own localhost, or on itself.
To get this to work on other machines, you will either need to migrate your database to a server that is more widely available (good idea) or somehow give the other computers network access to your computer (not a good idea).
But either way, the connection string will need to point to something else other than "localhost" or every computer that runs the app will try and find the database on itself.
Hope this helps!
Upvotes: 2