简体   繁体   中英

Installing a C# WPF application with local SQL Server database on another PC

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:

错误信息

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM