sql exception when transferring project from usb to c:\

Posted by jello on Stack Overflow See other posts from Stack Overflow or by jello
Published on 2010-03-07T00:15:56Z Indexed on 2010/03/09 2:21 UTC
Read the original article Hit count: 355

Filed under:
|
|
|

I'm working on a C# windows program with Visual Studio 2008. Usually, I work from school, directly on my usb drive. But when I copy the folder on my hard drive at home, an sql exception is unhandled whenever I try to write to the database. it is unhandled at the conn.Open(); line. here's the exception unhandled

Database 'L:\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' already exists. Choose a different database name. Cannot attach the file 'C:\Documents and Settings\Administrator\My Documents\system\project\the_project\the_project\bin\Debug\PatientMonitoringDatabase.mdf' as database 'PatientMonitoringDatabase'.

it's weird, because my connection string says |DataDirectory|, so it should work on any drive... here's my connection string:

string connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\PatientMonitoringDatabase.mdf; " +
                "Initial Catalog=PatientMonitoringDatabase; " +
                "Integrated Security=True";

© Stack Overflow or respective owner

Related posts about sql

Related posts about exception