0

I made a program with visual studio and after publishing and then installing on another machine, whenever it needs to access the database, it looks in the original project folder, where the connection string was made. "C:\Users\Cody\Dropbox\Visual Studio 11\Projects\OverPower\OverPower\opdata.sqlite" This path of course does not exist on another computer, which is why I am getting the error when it tries to access the database, but I thought that after publishing/deploying it would redirect to the installation directory to find this file. I've also tried making the file a resource and changing the connection string and file location of the database to the one above but going through the resources folder.

2
  • Please show us your code. Commented Jan 14, 2013 at 21:42
  • How do you build your connection string? Do you read it from a config file? If so, do you distribute this config file with your application? Commented Jan 14, 2013 at 21:47

1 Answer 1

2

I eventually found a post that made some serious sense and it even had a sample program to run and see how it works. I changed a few things and copied the settings.vb and ConnectionStringBuilder.vb classes to my project.

This is what my ConnectionStringBuilder Class looks like...

Dim path = Application.StartupPath + "\op_card.sqlite"
' Let's build our connection string.
Dim sqlConnString As New System.Data.SqlClient.SqlConnectionStringBuilder() With {
  .DataSource = path
}
Return sqlConnString.ConnectionString

and for the settings.vb class, I only changed the string found at the bottom, after the text, Me(, to the property name I found in the Settings.settings or My.Settings file. Here is the link to the article that helped me....

How to change default connection string setting during runtime

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.