Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Connectionstring With OpenFileDialog

$
0
0

How would one go about using a dynamic connection string without hardcoding it onto every page method?

Normally, I would just put it in the app.config, but some of the pages use an OpenFileDialog, which then uses the path of the file, causes the path to the database file to error out.  If I use: System.Windows.Forms.Application.StartupPath, it works great if I put the database in the /bin/debug folder, but as soon as I recompile the project, the database (Access) gets wiped out. 

How would I go about with one connection string that can be used for all pages / forms regardless of whether that pages uses an OpenFileDialog object or not?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>