Click here to Skip to main content
15,905,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I have a project with local database perfectly working on my PC but when I copy it on another PC it is not working. I have installed SqlLocalDb.msi file on another PC but still it is not working. This is my connection string:

What I have tried:

C#
<>string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ProfessorDb.mdf;Integrated Security=True;User Instance=True";



Can you please help me?
Posted
Updated 21-Feb-16 22:29pm
v2
Comments
Richard MacCutchan 22-Feb-16 4:21am    
What does "not working" mean?
PeMaCN 22-Feb-16 4:27am    
The error comes up but it is cought in try and catch so I cant tell you the text of error. Can you tell me how the connection string should look like if I want to use project on another PC?
CHill60 22-Feb-16 4:32am    
If the error is caught in a try/catch then you should be able to tell us the text - unless your catch block is empty - don't do that.
Use your debugger and let us know what the error is, otherwise we cannot possibly help you
Richard MacCutchan 22-Feb-16 4:54am    
Then your catch block is written incorrectly. Why do you think try/catch exists?

1 solution

First off, if you want to share data, then don't proliferate SQL instances: use a single instance that is visible to all machines that need to share the data, and don't attach a database - create it in the SQL server instance and use that. Attaching is a different process entirely, and it creates a "local copy" for your app's use only: Bad habits : Using AttachDBFileName - SQL Sentry[^]
If you don't want to share data, then don't use SQL Server: use Access, SQLCE, or SQLite instead as they require no server installation.
 
Share this answer
 
v2
Comments
OriginalGriff 22-Feb-16 5:58am    
How do you do which? :laugh:
Remember that we can't see your screen, access your HDD, or read your mind!

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