DataAdapter update problem

  • Thread starter Thread starter Kapti
  • Start date Start date
K

Kapti

Hi!

I save 10 rows per second to a Access DataBase.
Data are copied to DataSet pro term, then I call Update fuction of
DataAdapter to refresh database.
code:
DataRow newRow;
newRow = dataSet.GPS.NewRow();
newRow["distance"] = distance;
newRow["Longitude"] = Longitude;
newRow["Latitude"] = Latitude;
dataSet11.GPS.Rows.Add(newRow);
...
oleDbDataAdapter.Update(dataSet.GPS);

Update is very slow. At 10 row saving: about 0,07s
At 100 row saving: about 0,2s
Unfortunatelly, the program running break during Update.
Is the executing of Update really so slow?

I am looking forward to your answer.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Kapti,

Are you calling Update in a loop? If so, then you might want to
populate the data set first, then call update, otherwise, you are opening
and closing the connection to the DB every iteration through the loop.

Hope this helps.
 
Are you calling Update in a loop? If so, then you might want to
populate the data set first, then call update, otherwise, you are opening
and closing the connection to the DB every iteration through the
loop.

Solution:
Use OleDbCommand is the fastest way to insert a row to a database:

string insertString =@"insert into GPS (distance, longitude, Latitude)
values ('"+Distance+"','"+Longitude+"','"+Latitude+"')";
OleDbCommand cmd = new OleDbCommand(insertString, oleDbConnection);
cmd.ExecuteNonQuery();

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Back
Top