1

I am working on a Winforms application in C# using .NET 6.0.

The application has a SQL Server database with four tables. I have completed it and created setup.exe which successfully installs the application on my computer and works perfectly with the SQL Server Express database.

However, when I install it on another computer, I have problem to establish and connect database. I followed several instructions with no success. I even changed platform to .NET Framework 4.8 and followed tutorial to create localDb.

It works fine if I have only one table and one form with datagridview which follows table from database. But when I try interaction with other forms and tables it does not work.

It seems to me that only way is to install SQL Server Express on another computer and create the same connection string and same table, which I believe could not be the truth.

I saw a number of questions addressing the same problem, but there is no answers that solve it. I would be very thankful If anybody could suggest tutorial or article which addresses this topic.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ahmed.zubaca
  • 107
  • 2
  • 7
  • [How to deploy application with sql server database on clients](https://stackoverflow.com/a/32956485/3110834) – Reza Aghaei Feb 16 '22 at 01:25
  • i guess you've hardcoded the connection string? please paste your connection string and related configuration. – Lei Yang Feb 16 '22 at 01:42
  • I tried two different first: Data Source = .\SQLEXPRESS ; Initial Catalog = myDatabase; Integrated Security = True", and second Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\myDatabase.mdf;Integrated Security=True – ahmed.zubaca Feb 16 '22 at 07:39
  • Reaza Aghei, thanks for reaction to my question. I have seen this answer and tried to implement it. I managed to create setup which worked on another computer. But when I added second form to my application I was not able to connect to the table from that form. I noticed two different table, one which lives in Project file and another which lives in sql server express. These two table does not communicate with each other and changes on one does not cause changes to another. – ahmed.zubaca Feb 16 '22 at 07:57

0 Answers0