开发者

C# database file directory

I'm using the windows forms aplication with an ms access database. And i would like to know if there is a way to show the directory of the database file (to save data in it)excpet like this:

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=save.mdb";

        OleDbConnection empConnection = new OleDbConnection(conString);


        string insertStatement = "INSERT INTO zivila "
                             + "([naziv],[kalorij],[beljakovin],[oh],[mascob]) "
                   开发者_Python百科          + "VALUES (@naziv,@kalorij,@beljakovin,@oh,@mascob)";

or this:

  • "Data Source=D:\Simonova aktovka na namizju\matura\test5\save.mdb";

couse if i use the first one the aplication undos the changes i've made when i close it(the aplication) the second one makes me have to change the path everytime i bring the aplication to another computer(cous the direktory is different of coars) So... is there another way?


Try this:

Data Source=|DataDirectory|\save.mdb
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜