How do I allow a machine to connect to local SQL file

0

I'm currently working on an EPOS system for a friends shop, I'm currently getting him too test the features, making sure design etc is fine. I've set up the SQL Service Based Database, but the problem seems too be he is getting the error

System.Data.SqlClient.SqlException (0x80131904): 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.

I'm guessing this is because he hasn't got SQL Management server installed? I was wondering if there is anyway that I can include all of the required SQL files for him so that he can just open the program and then have it connect?

Pastebin

My connection string within my code:

  String connString = Settings.Default["DBConnectioNString"].ToString();
        SqlConnection conn = new SqlConnection(connString);
        if (conn.State != System.Data.ConnectionState.Open) conn.Open();

The DBConnectionString that is generated when creating the service based DB:

Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Databases\DB.mdf;Integrated Security=True

When I build the solution, it contains the database file exactly where I put it in VS17, any ideas on how I can make this work on his machine without him having to download SQL Management DB?

If someone can point me in the right direction, that would be appreciated, thank you.

c#
sql-server
windows
visual-studio
asked on Stack Overflow Apr 23, 2019 by Kevin Gorman

1 Answer

0

Install SQL Express server. And then use this:
string connectionString="Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\DatabaseFileName.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True";


You must have SQL server installed.

answered on Stack Overflow Apr 23, 2019 by Alexandru Banu

User contributions licensed under CC BY-SA 3.0