views:

51

answers:

1

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]) "
                             + "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?

A: 

Try this:

Data Source=|DataDirectory|\save.mdb
Veer
nope. IT deletes the stuff a have put in
Simon
I think you should add some code to your question showing how you use this.
Remou
@Simon: How do you say it deletes the stuff. Are you sure you are checking the save.mdb inside your solution folder where your project resides?
Veer
yes. But i tried it again and it's like this. If i use it like this:Data Source=save.mdb"; It saves the data in it. And until i close the aplication the data is useable.But if i restart the aplication the new data is not in the database anymore.if i write the whole path. The data i record isn't useable . I have to restart the aplication, and the data i inserted before is useable.
Simon