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)
'MsgBox("Server Connection is Open ! ")
'frmMain.Connection.Text = "Connecting To serv``er"
Catch ex As Exception
MsgBox("Sorry Can not open connection ! ", vbCritical, "Database")
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?
In order for the other computers on the network to access the DB hosted on your computer, you will need to leave SQLExpress running.
The other machines would then use a connection string something like: connectionString="Data Source=" & YOUR_COMPUTER_NAME & "\SQLEXPRESS;InitialCatalog=" & YOUR_DATABASE_NAME & ";Integrated Security=True;User Instance=True"
Where YOUR_COMPUTER_NAME is the hostname of your computer AND YOUR_DATABASE_NAME is the internal name of the database (the name that appears in Server Explorer on your machine with the db attached)
Hi, Thanks for your post, But I will publish this and make it executable, how will i change it dynamically such that the first time the users use thisapp, it will try to connect to the database, if not connected, it will prompt something to user then ask to select server and database? Im trying to modify the app.config but seems not updating
I didn't mark it solved yet coz im still having trouble with this. Sorry for that From my orig post im focusing on hard coded form (module) to communicate with the database but with some googling, I found that the app.config can be used and can be modified during run time, that's why on this post I focused on using app.config, but during run time it seems that the app.config is not updating. Reading from forums also said that i might having problem with my sql since its express edition. IM still working on upgrading it, uninstalling it then installing the production version (I think if im not mistaken) sadly cant find my installation cd, the product key is there.