Reputation: 2873
I developed a simple winforms app, with a service-based DB with it.
When running the app on my machine it works fine. But after publishing the app and place it on the other machine it installs and runs normally but when it comes to connecting to the DB it throws an error.
"An attempt to attach auto-named database for file"
Using the below connection string:
<connectionStrings>
<add name="MyConString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\myDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Calling the connection as:
static string constr = System.Configuration.ConfigurationManager.ConnectionStrings["MyConString"].ConnectionString;
static SqlConnection conn = new SqlConnection(constr);
having SQL server installed on the targeted machine...
am i missing something ?
Upvotes: 0
Views: 89
Reputation: 2873
The below link is a step by step tutorial to deploy an application, through creating a setup:
http://www.codeproject.com/Articles/12548/Visual-Studio-Windows-Application-Setup-Project
Upvotes: 0
Reputation: 133
You should change datasource name where database exist "." means it exists on local machine. If you don't want to change datasource name then you should put database on same system.
Upvotes: 1
Reputation: 19
Data Source=.\SQLEXPRESS The "." here means Sql server database on your local machine. If you deploy this application to another machine, you have to change "." to your local machine IP address(assume they are in same local network).
Upvotes: 1