By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,195 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,195 IT Pros & Developers. It's quick & easy.

Copy DataSet problem

P: n/a
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?
Feb 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 2, 6:04 am, henfo <h...@discussions.microsoft.comwrote:
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.

Feb 2 '07 #2

P: n/a

"Ralph" <ra******@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
On Feb 2, 6:04 am, henfo <h...@discussions.microsoft.comwrote:
>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.
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.
Feb 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.