Copy DataSet problem

G

Guest

Hi,
I am working on program to cop data from the main database (Oracle or SQL
Server) to a local Access-database used on laptops. The databse is quite
large so the routine nedds to be fast.

The stripped down code looks like this:

OleDbCommand cmd = new OleDbCommand("SELECT * FROM Table",
connServer);
OleDbDataAdapter daServer = new OleDbDataAdapter(cmd);
DataSet dsServer = new DataSet();
daServer.Fill(dsServer);

DataSet dsLocal = dsServer.Copy();
// So far everything is OK

OleDbCommand cmd2 = new OleDbCommand("UPDATE Table SET CopyDate
= '" + DateTime.Now + "'", connLocal);
OleDbDataAdapter daLocal = new OleDbDataAdapter(cmd2);
daLocal.Update(dsLocal);
cmd2.ExecuteNonQuery();

Nothing happens in the Access database. dsLocal.HasChanges() is False when I
check. Why? What am I missing?
 
R

Ralph

Hi,
I am working on program to cop data from the main database (Oracle or SQL
Server) to a local Access-database used on laptops. The databse is quite
large so the routine nedds to be fast.

The stripped down code looks like this:

OleDbCommand cmd = new OleDbCommand("SELECT * FROM Table",
connServer);
OleDbDataAdapter daServer = new OleDbDataAdapter(cmd);
DataSet dsServer = new DataSet();
daServer.Fill(dsServer);

DataSet dsLocal = dsServer.Copy();
// So far everything is OK

OleDbCommand cmd2 = new OleDbCommand("UPDATE Table SET CopyDate
= '" + DateTime.Now + "'", connLocal);
OleDbDataAdapter daLocal = new OleDbDataAdapter(cmd2);
daLocal.Update(dsLocal);
cmd2.ExecuteNonQuery();

Nothing happens in the Access database. dsLocal.HasChanges() is False when I
check. Why? What am I missing?

I'm going to take a guess here, but I see two potential things to look
into.
One I believe you will need to do a fill first with daLocal, with a
select command.
Okay I could be off on that it may have changed since 1.1 to 2.0.
2, I don't believe you actually change dsLocal unless you do in code
that isn't visible.
 
R

RobinS

Ralph said:
I'm going to take a guess here, but I see two potential things to look
into.
One I believe you will need to do a fill first with daLocal, with a
select command.
Okay I could be off on that it may have changed since 1.1 to 2.0.
2, I don't believe you actually change dsLocal unless you do in code
that isn't visible.

I think your second answer is right. The underlying row states say the data
is Unmodified, so when you do an update using the data adapter, it doesn't
find any rows that are not unmodified.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top