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?

Recommended Answers

All 6 Replies

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?

Are you sure you only defined the connection in this string?

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"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.