How do you use the connection string on a local database in a way that would allow you to transfer the project folder from one computer to another, without having to modify the connection string?
Not like this
connection_String As String = "Data Source=C:\Users\Kyle\Desktop\CSCI_388_Group_Project\CSCI_388_Group_Project\CSCI_388_Group_Project\CSCI_388_Group_Project_Database.sdf"
More like this
connection_String As String = "Data Source=|DataDirectory|\CSCI_388_Group_Project_Database.sdf"
If I try to enter the second example into the connection field under the database properties I get an illegal character error.
The Environment class contains most of the paths you’ll need.
You can call
Environment.GetFolderPathto get a special directory. For example, to get the My Documents directory, callEnvironment.GetFolderPath(Environment.SpecialFolder.Personal).You can browse all of the special folders here:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
In your example specifically, you’d use the following:
Alternative:
Is it possible to just ask the user? If it’s on their desktop, they might move it.