Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello everyone.
I need to build stand alone (WinApp+Database) for install on another PC.
When work on my PC i'm import database file (.dbf) to my Windows Application project, it's work fine.
But when install this project on another PC it does'n work and get this error (see the link below.)
https://www.dropbox.com/s/ztz5d1dobtgd1c9/error.png?dl=0[^]
i'm using SQLServer 2012 Express

Here is connection String. C# (Does'n work)
C#
static string directory = Path.GetDirectoryName(Application.ExecutablePath);
        SqlConnection Con = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=" + directory + "\\Database.mdf;Integrated Security=True");

(*update)
Here is Connection String VB (This connection string working on another PC)
Is It Possible to convert to C#?
SQL
Public conStr As String = "Data Source=.\SQLEXPRESS;" & _
        "AttachDbFilename=|DataDirectory|\Database.mdf;" & _
        "Integrated Security=True;User Instance=True"
Posted
Updated 21-Mar-15 6:46am
v3

"The server was not found or was not accessible"

What do you think that means?
Look at your data source: (LocalDB)\\v11.0
That's fine for a development machine, but in production it is very, very unlikely to be right. You need to have a connections string that is stored in a parameter file of some description which allows it to be changed to address the actual SQL Server instance to be found at the client.

I can't help you work out what that is: that's down to you when you installed your application.
 
Share this answer
 
Comments
terzasek 21-Mar-15 12:47pm    
Thank for you suggest. Can you review my question,What should i do?
OriginalGriff 21-Mar-15 12:59pm    
You need to find out the name of the actual SQL server...
".\SQLEXPRESS" is a local instance - which is very, very unlikely in production!
I have to create Database.mdf in my project on Visual Studio and use this code below.
C#
SqlConnection Con = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;UserInstance=True");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900