I have done my vb.net application and ready for deployment, my database is located somewhere in my drive c:, i used this code to get connection string from app.config
Public Sub main() constr = System.Configuration.ConfigurationManager.ConnectionStrings("WindowsApplication7.My.MySettings.nameConnectionString").ToString Con = New SqlConnection(constr) Try Con.Open() 'MsgBox("Server Connection is Open ! ") 'frmMain.Connection.Text = "Connecting To serv``er" Con.Close() Catch ex As Exception MsgBox("Sorry Can not open connection ! ", vbCritical, "Database") End Try End Sub
and my app.config has this code
<?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="WindowsApplication7.My.MySettings.nameConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DATA\database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration>
On my local machine when i tried to run my application, it cannot find the database save to c:.
The database was embeded on my application folder before, since i will install it to different computers, I decided to remove it and save somewhere in c:, how will i modify my code such that even in different computers they still can access my database?
thank you so much for any help