problem with inserting data to access db
-
i'm trying to insert data to access db, and i did it, but the problem is after first insert when check the db data is there, then close the application and run it again the last inserted data is missing, what might be the problem.
-
i'm trying to insert data to access db, and i did it, but the problem is after first insert when check the db data is there, then close the application and run it again the last inserted data is missing, what might be the problem.
Actually the senerio is not clear, Probably you using a datatable with a disconnect recordset, Try to directly insert.
Md. Marufuzzaman
-
Actually the senerio is not clear, Probably you using a datatable with a disconnect recordset, Try to directly insert.
Md. Marufuzzaman
no i'm using oleDbDataAdapter1,dataSet11,oleDbConnection1 and following s the code
DataRow dr = dataSet11.Table1.NewRow();
dr["ic"] = txt1.Text;
dr["DES"] = txt2.Text;
dr["STKBAL"] = txt3.Text;oleDbConnection1.Open(); dataSet11.Table1.Rows.Add(dr); oleDbDataAdapter1.Fill(dataSet11); oleDbDataAdapter1.Update(dataSet11,"table1"); oleDbConnection1.Close();
-
i'm trying to insert data to access db, and i did it, but the problem is after first insert when check the db data is there, then close the application and run it again the last inserted data is missing, what might be the problem.
Check all the stored procedures/SQL queries that are fired on the DB until you close your application. If the data has been inserted, it can vanish only if some command that does so is run. Had it been SQL server, Profiler would have helped you out. Don't know if it works with Access or there is something like that for Access DB too.
-
no i'm using oleDbDataAdapter1,dataSet11,oleDbConnection1 and following s the code
DataRow dr = dataSet11.Table1.NewRow();
dr["ic"] = txt1.Text;
dr["DES"] = txt2.Text;
dr["STKBAL"] = txt3.Text;oleDbConnection1.Open(); dataSet11.Table1.Rows.Add(dr); oleDbDataAdapter1.Fill(dataSet11); oleDbDataAdapter1.Update(dataSet11,"table1"); oleDbConnection1.Close();
Ummm... you're adding a DataRow to a DataTable in a DataSet then filling the DataSet with the contents of the database? Doesn't that wipe out the existing data in the DataSet? :confused: Other than that; why are you using a DataSet and a DataAdapter? You probably just want to use ExecuteNonQuery to add the data.
-
i'm trying to insert data to access db, and i did it, but the problem is after first insert when check the db data is there, then close the application and run it again the last inserted data is missing, what might be the problem.
if you are running your application from visual studio and your access db file is added to project right click on your access db file, select properties, and set "copy to output directory" to "copy if newer" hope it helps :)
Let there arise out of you a band of people inviting to all that is good, enjoining what is right, and forbidding what is wrong: They are the ones to attain felicity. Āli-'Imrān (The Family of Imran), 104.
-
no i'm using oleDbDataAdapter1,dataSet11,oleDbConnection1 and following s the code
DataRow dr = dataSet11.Table1.NewRow();
dr["ic"] = txt1.Text;
dr["DES"] = txt2.Text;
dr["STKBAL"] = txt3.Text;oleDbConnection1.Open(); dataSet11.Table1.Rows.Add(dr); oleDbDataAdapter1.Fill(dataSet11); oleDbDataAdapter1.Update(dataSet11,"table1"); oleDbConnection1.Close();