how to make publish file in window form application with local .mdf file that work on any other pc

huangapple go评论74阅读模式
英文:

how to make publish file in window form application with local .mdf file that work on any other pc

问题

我使用本地 Database.mdf 文件进行简单的 curd 操作,当我发布 .exe 文件时,在我的开发笔记本上正常工作,但当我移动到其他笔记本时,它给我这个错误。

how to make publish file in window form application with local .mdf file that work on any other pc

我的连接字符串如下:

cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True");
英文:

i make simple curd operation with local Database.mdf file and when i make publish it .exe file work fine on my developement laptop but when i move to any other laptop it give me this error.
how to make publish file in window form application with local .mdf file that work on any other pc

and my connection string look like this
cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True");

please help me if any one face this type issue in window form application thanks

答案1

得分: 1

你必须在目标计算机上安装SQL Server Express LocalDB

如果您正在寻找一个真正自包含的数据库,可以将其与您的应用程序一起分发,并且无需任何远程服务器或特定设置即可运行,您可以尝试SQLite

LocalDB 不是自包含的。

英文:

You must install SQL Server Express LocalDB on the target machine.

If you are looking for a truly self-contained database that can be shipped with your application and run "as-is" without any remote servers or specific setup, you could try <a href="https://www.sqlite.org/">SQLite</a>.

LocalDB is not self-contained.

huangapple
  • 本文由 发表于 2023年4月13日 22:03:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76006382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定