Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem with connecting to my local database file after installation this is my connection string

private const string constr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\HuskyCenter.mdf;Integrated Security=True";

before I didn't have this problem and now I don't know what is happening when I install my app on my pc or another pc this what it will show below[^]

What I have tried:

I have tired to change the connection string but it got worse so I didn't do anything else
Updated 4-Jan-21 21:01pm
PIEBALDconsult 1-Jan-21 19:52pm    
Is the PC running in a domain? Is ;Integrated Security=True correct for it?
Member 15035289 1-Jan-21 19:55pm    
I'm making an offline app, so in VS there is no problem connecting to the mdf file
but after installation, I have this problem, before I start finishing my project I tested it and it worked fine on my main pc and my other pc but now I cant connect to the mdf file on both
Dave Kreskowiak 1-Jan-21 22:12pm    
Does the machine have SQL Server installed on it?
CHill60 4-Jan-21 12:04pm    
Do you have somewhere
AppDomain.CurrentDomain.SetData("DataDirectory", "C:\...");
where the ... is the folder containing your .MDF?

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900