2

I have a question that I have developed a C# WPF application which requires a local SQL Server database. I am having trouble publishing the application to a different computer where there is no SQL Server installed.

Is it necessary for me to have a SQL Server installed on all the PCs where I am going to install my application? Or am I missing something?

I am making the setup file form Advance Installer and copying the .mdf database to the location mentioned in the connection string

string connectionString = @"Data Source =(LocalDB)\MSSQLLocalDB; AttachDbFilename = " + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\abc\Databases\abc.mdf; Integrated Security = True; Connect Timeout = 30";

The error I am getting:

error message

If having a SQL Server a necessity, which one should I install on a low end pc? any help will be appreciated. Thank you

1

1 Answer 1

3

If you want to use a .mdf file, then you must have SQL Server installed

  • either locally on each PC
  • or centrally on a server which all the PC's can connect to

If you install a .mdf file locally on a PC and you want to use the AttachDbFileName= parameter in your connection string, then you must install SQL Server Express on each PC that has this application. Other editions of SQL Server do NOT support the AttachDbFileName= approach.

Sign up to request clarification or add additional context in comments.

3 Comments

okay the answer is very clear thankyou, but what if i do not use the .mdf file? what are the other ways to achieve the goal?
@YasarKhalid: Not sure what you're asking - you could of course use a different database system - like SQLite or others - that do not require an installation of server components - but that means changing all your database code ...
thankyou for your solution, i am going for one local server, and i am going to use 1 central database for two systems over the LAN, but the (database or the server) is only allowing only one connection at a time, how to have two or more concurrent connections for one database? any help? @marc_s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.