ive been able to succesfully link a mdf databse to a vb.net program.My program runs flawlessly but if i change the location of the database from e:\new\xyz.mdf to c:\new\xyz.mdf then it throws an exception :
System.Data.SqlClient.SqlException' occurred in System.Data.dll

SQLConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename= e:\new\xyz.mdf;Initial Catalog=xyz;Integrated Security=True;User Instance=True"

And what do i need to do to run my application on other computers?

8 Years
Discussion Span
Last Post by karan khokhar

And you don't see the problem?

Share the drive over the network and put the network path instead of e:\new\xyz.mdf


i think it was a sql express issue. it will open duplicate files .I had the same file in c:\new and e:\new .when i tried opening the c:\new file via VB.NET sqlconnection it was throwing an exception .

I removed the try catch code and ran the program it threw an error that it will not open a database which already exists someplace else.

but now the problem is that if i cut the file in e:\new and paste it in c:\new it still wont open but if i copy the same file from e:\new to c:\new and rename that file to something else the program runs flawlessly .any ideas to work around this?


well actually the connection string is:
SQLConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='" & a & "';Initial Catalog='" & f & "';Integrated Security=True;User Instance=True"


Use different 'attach name' for initial catalog.

SQLConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename= e:\new\xyz.mdf;Initial Catalog=xyz1;Integrated Security=True;User Instance=True"

problem persists ive changed the connection string to:

SQLConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='" & a & "';Initial Catalog='" & f + "1" & "';Integrated Security=True;User Instance=True"

Edited by karan khokhar: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.