How can I run C# app which contains local SQL Server database on another computer?

Petar Bechev picture Petar Bechev · Jan 29, 2016 · Viewed 11.6k times · Source

I have created a C# program with a SQL Server database. It works fine on my computer but on my friend's PC it doesn't (my friend doesn't have SQL Sever 2008). Is it possible to make it without any installation? And if it can, how can it be done?

This is my connection string:

connectionString="Data Source=\v11.0;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;Integrated Security=True"

Answer

Mike Tsayper picture Mike Tsayper · Jan 29, 2016

SQL Server is for server databases. You can change your project to use SQL Server CE (SQL Server Compact Edition) which is a single-file local database. It is very similar to the "true" SQL Server so it may be the easiest solution. Your code probably wont change except for the connection string.