Can another string be used in Data Source instead of DataDirectory?
Posted: Sat 30 Nov 2019 04:07
Hi,
To avoid hard coding I am not using database path for Data Source. Instead of it, I am using |DataDirectory| and code in Form Loading like: When I changed the database structure, I had to connect to the old database and upgrade the data to the new database. For this reason, I need to connect to the new database at the start of the program and the old database while clicking Browse button.
But when I use DataDirectory on both, I get an error. When I define another string instead of DataDirectory, for example, DataNewDirectory, in the model page like `<Connection Mode="ConnectionString" ConnectionString="Data Source=|DataNewDirectory|" Provider="Devart.Data.SQLite" />` I got "Illegal characters in path." error. How do I manage this?
To avoid hard coding I am not using database path for Data Source. Instead of it, I am using |DataDirectory| and code in Form Loading like:
Code: Select all
AppDomain.CurrentDomain.SetData("DataDirectory", Settings.DataPath);
But when I use DataDirectory on both, I get an error. When I define another string instead of DataDirectory, for example, DataNewDirectory, in the model page like `<Connection Mode="ConnectionString" ConnectionString="Data Source=|DataNewDirectory|" Provider="Devart.Data.SQLite" />` I got "Illegal characters in path." error. How do I manage this?