views:

51

answers:

1

hi, I just tried a simple code(in C#) which adds a record to a table in my access data base. I just added the data base in visual studio by "Add => Existing Item..." to my project and then in the data set that was created automatically after adding the data base I added a simple INSERT query. now here is my code :

here this code does not seem work :

Database2DataSetTableAdapters.Table1TableAdapter adapter = new WindowsFormsApplication4.Database2DataSetTableAdapters.Table1TableAdapter();
adapter.InsertQuery("one", "22");

and even this way :

 Database2DataSet.Table1DataTable tb1 = new Database2DataSet.Table1DataTable();
            Database2DataSet.Table1Row row = tb1.NewTable1Row();
            row.Name = "hey";
            row.Tel = "45454";
            tb1.Rows.Add(row);
            Database2DataSetTableAdapters.Table1TableAdapter adapter = new Database2DataSetTableAdapters.Table1TableAdapter();
            adapter.Update(tb1);

but seems update does not work and i cannot see the added records to my data base when ever I try to retrive data from the data base within the visual studio's server explorer or MS Access when I open the data base file(Even no exceptions occurs):( some say vs makes a copy of the data base in Bin folder how can I stop that so I can add records directly to the main access data base and I can edit those records by openning the data base in the MS Access. Tnx.

A: 

As yourself said, VS copy the used file of the program to the bin directory. You can't stop it otherwise your program will stop working altogether. Simply modify the DB in your app and then copy back from the bin/release folder the access DB back into the project folder. :)

feal87
that's right but I thought may be it is possible to do such a thing. tnx anyway
ramtinova