简体   繁体   中英

Transferring winforms app with local db to other computers

I have built an app with winforms application and added a local database to my project using based-data source.

on the app load event the app connects to the database and loads its components accordingly.

everything works fine on my pc but the problem is when I am transferring the app to other computers. I am getting an error every time the app tries to connect to the database (local Database Run time error occurred).

Tried to install SQL Express localdb 12 on the other computers and checked that the service: SQL Server VSS Writer is running but still getting the same error. Note: the database.mdf file exists in the same location on all the computers.

SQL Error:

在此处输入图片说明

How can I fix it?

I suggest not to hard-code connection string in code. Move connection string in configuration file and access from their and rebuild your application. Now when you move your project to other computer, you move configuration file which is generated by build as well. On new computer, open DB and freshly copy your connection string and replace it in your configuration file and then run your application. Hope this will help.

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