When I do a good student management system, I found that to use the software must configure the database data source. So I wanted to get out of the data source version.
Tectonic thinking:
In Con1 ConnectionString has a link database file as a data source, then we can configure the data source with the database file.
So Baidu a bit data Source = DataSource path. The student data source is registered in the registry and the student data source name is equivalent to the path.
Ideas:
The first step: immediately think of to get the absolute path of the database.
Step Two: Code connectionstring, provider to write the driver name of the full data provider (such as
Provider=Microsoft.Jet.OLEDB.4.0 (Access data Engine)
, and data source is written as an absolute path.
Technical key:
1. Get the program directory, construct absolute path:
sDBPath = Extractfilepath (application. exename) + ' Dataname.mdb ';
2.con1. ConnectionString: = ' provider=microsoft.jet.oledb.4.0;data source= ' + sDBPath + ';
Steps:
One: There is such an interface