473,903 Members | 3,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataAdapter Not Updating

Hi,
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the connection
it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the
connection to the DataBase is not successful, it reloads the last know good
DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on demand )
update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug
Nov 21 '05 #1
13 2102
To Update the Database, you need to have an Update statement. You can try to
use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each item to be
updated. The statement it builds is complex, and a bit daunting.

You could just use the values from the controls that represent the record to
be updated, and concatenate an Update statement for each database table. Set
the CommandText property of your OleDbCommand to the Update string. Then
open your connection and run the Command.Execute NonQuery method. Then close
the connection.

This is the old fashioned way of getting data back to the data store, but I
think it really is easier and more straight forward than using the
CommandBuilder. You could still assign the various OleDbCommand objects to a
DataAdapter, if you prefer, but you still need to create and assign the
CommandText for the Commands. Test it though because I think that
DataAdapter.Upd ate runs the Insert and Delete Commands too, if such changes
have been made to a datatable.

My preference is to use the DataAdapter to Fill, and stand alone Commands to
write back.

Of course, if you build your own statements, be sure to set your WHERE
clause to the primary key of the record being updated. Most of us have
omitted that at least once, and gasped when ALL records got updated.

www.charlesfarriersoftware.com

"Doug Bell" wrote:
Hi,
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the connection
it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the
connection to the DataBase is not successful, it reloads the last know good
DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on demand )
update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug

Nov 21 '05 #2
Charlie,
I do not want to update the Database!

I want to update 4 of the 6 DataTables in the DataSet!

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:34******** *************** ***********@mic rosoft.com...
To Update the Database, you need to have an Update statement. You can try to use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each item to be updated. The statement it builds is complex, and a bit daunting.

You could just use the values from the controls that represent the record to be updated, and concatenate an Update statement for each database table. Set the CommandText property of your OleDbCommand to the Update string. Then
open your connection and run the Command.Execute NonQuery method. Then close the connection.

This is the old fashioned way of getting data back to the data store, but I think it really is easier and more straight forward than using the
CommandBuilder. You could still assign the various OleDbCommand objects to a DataAdapter, if you prefer, but you still need to create and assign the
CommandText for the Commands. Test it though because I think that
DataAdapter.Upd ate runs the Insert and Delete Commands too, if such changes have been made to a datatable.

My preference is to use the DataAdapter to Fill, and stand alone Commands to write back.

Of course, if you build your own statements, be sure to set your WHERE
clause to the primary key of the record being updated. Most of us have
omitted that at least once, and gasped when ALL records got updated.

www.charlesfarriersoftware.com

"Doug Bell" wrote:
Hi,
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the connection it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the connection to the DataBase is not successful, it reloads the last know good DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on demand ) update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug

Nov 21 '05 #3
Calling the DataAdapter update method activates the Insert, Update, and
Delete commands that are assigned to the DataAdapter. If you are trying to
refresh the data in a datatable from the database, you can use the
Datatable.Rows. Clear method, and then used the DataAdapter Fill method again
using the DataAdapter you have set up for that Datatable.

Did I understand you correctly this time?

"Doug Bell" wrote:
Charlie,
I do not want to update the Database!

I want to update 4 of the 6 DataTables in the DataSet!

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:34******** *************** ***********@mic rosoft.com...
To Update the Database, you need to have an Update statement. You can try

to
use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each item to

be
updated. The statement it builds is complex, and a bit daunting.

You could just use the values from the controls that represent the record

to
be updated, and concatenate an Update statement for each database table.

Set
the CommandText property of your OleDbCommand to the Update string. Then
open your connection and run the Command.Execute NonQuery method. Then

close
the connection.

This is the old fashioned way of getting data back to the data store, but

I
think it really is easier and more straight forward than using the
CommandBuilder. You could still assign the various OleDbCommand objects

to a
DataAdapter, if you prefer, but you still need to create and assign the
CommandText for the Commands. Test it though because I think that
DataAdapter.Upd ate runs the Insert and Delete Commands too, if such

changes
have been made to a datatable.

My preference is to use the DataAdapter to Fill, and stand alone Commands

to
write back.

Of course, if you build your own statements, be sure to set your WHERE
clause to the primary key of the record being updated. Most of us have
omitted that at least once, and gasped when ALL records got updated.

www.charlesfarriersoftware.com

"Doug Bell" wrote:
Hi,
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the connection it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the connection to the DataBase is not successful, it reloads the last know good DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on demand ) update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug


Nov 21 '05 #4
Charlie,
Yes, that is what I want to achieve.
I realise that the DataAdapter eficiently streams data. I was hoping that it
could use DeltaGrams like the Update uses to update the Database Tables but
I guess that would require the Database keeping track of the data that it
had originally streamed down.

If the connection fails between the start of clearing the data and the then
the reloading using the Fill Method is there any way to roll back like in a
transaction?

Thanks

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
Calling the DataAdapter update method activates the Insert, Update, and
Delete commands that are assigned to the DataAdapter. If you are trying to refresh the data in a datatable from the database, you can use the
Datatable.Rows. Clear method, and then used the DataAdapter Fill method again using the DataAdapter you have set up for that Datatable.

Did I understand you correctly this time?

"Doug Bell" wrote:
Charlie,
I do not want to update the Database!

I want to update 4 of the 6 DataTables in the DataSet!

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:34******** *************** ***********@mic rosoft.com...
To Update the Database, you need to have an Update statement. You can try
to
use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each
item to be
updated. The statement it builds is complex, and a bit daunting.

You could just use the values from the controls that represent the
record to
be updated, and concatenate an Update statement for each database
table. Set
the CommandText property of your OleDbCommand to the Update string.
Then open your connection and run the Command.Execute NonQuery method. Then

close
the connection.

This is the old fashioned way of getting data back to the data store, but I
think it really is easier and more straight forward than using the
CommandBuilder. You could still assign the various OleDbCommand
objects to a
DataAdapter, if you prefer, but you still need to create and assign
the CommandText for the Commands. Test it though because I think that
DataAdapter.Upd ate runs the Insert and Delete Commands too, if such

changes
have been made to a datatable.

My preference is to use the DataAdapter to Fill, and stand alone Commands to
write back.

Of course, if you build your own statements, be sure to set your WHERE
clause to the primary key of the record being updated. Most of us
have omitted that at least once, and gasped when ALL records got updated.

www.charlesfarriersoftware.com

"Doug Bell" wrote:

> Hi,
> I thought I had this sorted this morning but it is still a problem.
>
> My application has a DataAccess Class.
>
> When it starts, it:
> Connects to a DB (OLE DB)
> If it connects it uses an OleDbCommand with an SQL String and the

connection
> it has a DataAdapter with the command
> then it fills the DataSet's DataTable with the streamed data.
>
> It does this for 6 DataTables,
> then it closes the connection.
>
> That all works fine including saving the DataSet to an XML file and if the
> connection to the DataBase is not successful, it reloads the last
know good
> DataSet from the pre-Saved XML.
>
> What I am trying to achieve is to periodically (once an hour or on

demand )
> update 4 of the DataTables from the DataBase.
>
> The code for this is:
>
> ConnectMyDB() sub to connect to the Database
>
> If MyDBConnected Then
> If Not HasDownloaded Then
> 'Do the first download stuff
> Else
> daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
> daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
> daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
> daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
> End If
>
> This runs without error but the DataSet is not updated with any of

the > changes that have occured at the DataBase.
>
> Am I missing something?
>
> Thanks Doug
>
>
>


Nov 21 '05 #5
You could open the connection in a try block before clearing the datatable
rows. Do you have trouble with connections failing after a successful open?
If so, could you use the xml file your referred to in the first post as your
backup?

"Doug Bell" wrote:
Charlie,
Yes, that is what I want to achieve.
I realise that the DataAdapter eficiently streams data. I was hoping that it
could use DeltaGrams like the Update uses to update the Database Tables but
I guess that would require the Database keeping track of the data that it
had originally streamed down.

If the connection fails between the start of clearing the data and the then
the reloading using the Fill Method is there any way to roll back like in a
transaction?

Thanks

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
Calling the DataAdapter update method activates the Insert, Update, and
Delete commands that are assigned to the DataAdapter. If you are trying

to
refresh the data in a datatable from the database, you can use the
Datatable.Rows. Clear method, and then used the DataAdapter Fill method

again
using the DataAdapter you have set up for that Datatable.

Did I understand you correctly this time?

"Doug Bell" wrote:
Charlie,
I do not want to update the Database!

I want to update 4 of the 6 DataTables in the DataSet!

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:34******** *************** ***********@mic rosoft.com...
> To Update the Database, you need to have an Update statement. You can try to
> use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each item to be
> updated. The statement it builds is complex, and a bit daunting.
>
> You could just use the values from the controls that represent the record to
> be updated, and concatenate an Update statement for each database table. Set
> the CommandText property of your OleDbCommand to the Update string. Then > open your connection and run the Command.Execute NonQuery method. Then
close
> the connection.
>
> This is the old fashioned way of getting data back to the data store, but I
> think it really is easier and more straight forward than using the
> CommandBuilder. You could still assign the various OleDbCommand objects to a
> DataAdapter, if you prefer, but you still need to create and assign the > CommandText for the Commands. Test it though because I think that
> DataAdapter.Upd ate runs the Insert and Delete Commands too, if such
changes
> have been made to a datatable.
>
> My preference is to use the DataAdapter to Fill, and stand alone Commands to
> write back.
>
> Of course, if you build your own statements, be sure to set your WHERE
> clause to the primary key of the record being updated. Most of us have > omitted that at least once, and gasped when ALL records got updated.
>
> www.charlesfarriersoftware.com
>
> "Doug Bell" wrote:
>
> > Hi,
> > I thought I had this sorted this morning but it is still a problem.
> >
> > My application has a DataAccess Class.
> >
> > When it starts, it:
> > Connects to a DB (OLE DB)
> > If it connects it uses an OleDbCommand with an SQL String and the
connection
> > it has a DataAdapter with the command
> > then it fills the DataSet's DataTable with the streamed data.
> >
> > It does this for 6 DataTables,
> > then it closes the connection.
> >
> > That all works fine including saving the DataSet to an XML file and if the
> > connection to the DataBase is not successful, it reloads the last know good
> > DataSet from the pre-Saved XML.
> >
> > What I am trying to achieve is to periodically (once an hour or on
demand )
> > update 4 of the DataTables from the DataBase.
> >
> > The code for this is:
> >
> > ConnectMyDB() sub to connect to the Database
> >
> > If MyDBConnected Then
> > If Not HasDownloaded Then
> > 'Do the first download stuff
> > Else
> > daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
> > daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
> > daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
> > daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
> > End If
> >
> > This runs without error but the DataSet is not updated with any of the > > changes that have occured at the DataBase.
> >
> > Am I missing something?
> >
> > Thanks Doug
> >
> >
> >


Nov 21 '05 #6
You could also create a new Datatable and copy the original.
dim DT2 as new datatable()
DT2 = DT1.Copy
This creates an independent datatable object that you could use in case of
connection failure.
"Charlie" wrote:
You could open the connection in a try block before clearing the datatable
rows. Do you have trouble with connections failing after a successful open?
If so, could you use the xml file your referred to in the first post as your
backup?

"Doug Bell" wrote:
Charlie,
Yes, that is what I want to achieve.
I realise that the DataAdapter eficiently streams data. I was hoping that it
could use DeltaGrams like the Update uses to update the Database Tables but
I guess that would require the Database keeping track of the data that it
had originally streamed down.

If the connection fails between the start of clearing the data and the then
the reloading using the Fill Method is there any way to roll back like in a
transaction?

Thanks

Doug

"Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
news:23******** *************** ***********@mic rosoft.com...
Calling the DataAdapter update method activates the Insert, Update, and
Delete commands that are assigned to the DataAdapter. If you are trying

to
refresh the data in a datatable from the database, you can use the
Datatable.Rows. Clear method, and then used the DataAdapter Fill method

again
using the DataAdapter you have set up for that Datatable.

Did I understand you correctly this time?

"Doug Bell" wrote:

> Charlie,
> I do not want to update the Database!
>
> I want to update 4 of the 6 DataTables in the DataSet!
>
> Doug
>
> "Charlie" <cfarrier at charlesfarriers oftware.com> wrote in message
> news:34******** *************** ***********@mic rosoft.com...
> > To Update the Database, you need to have an Update statement. You can

try
> to
> > use the OleDb.OleDbComm andBuilder, and an OleDB.Parameter for each

item to
> be
> > updated. The statement it builds is complex, and a bit daunting.
> >
> > You could just use the values from the controls that represent the

record
> to
> > be updated, and concatenate an Update statement for each database

table.
> Set
> > the CommandText property of your OleDbCommand to the Update string.

Then
> > open your connection and run the Command.Execute NonQuery method. Then
> close
> > the connection.
> >
> > This is the old fashioned way of getting data back to the data store,

but
> I
> > think it really is easier and more straight forward than using the
> > CommandBuilder. You could still assign the various OleDbCommand

objects
> to a
> > DataAdapter, if you prefer, but you still need to create and assign

the
> > CommandText for the Commands. Test it though because I think that
> > DataAdapter.Upd ate runs the Insert and Delete Commands too, if such
> changes
> > have been made to a datatable.
> >
> > My preference is to use the DataAdapter to Fill, and stand alone

Commands
> to
> > write back.
> >
> > Of course, if you build your own statements, be sure to set your WHERE
> > clause to the primary key of the record being updated. Most of us

have
> > omitted that at least once, and gasped when ALL records got updated.
> >
> > www.charlesfarriersoftware.com
> >
> > "Doug Bell" wrote:
> >
> > > Hi,
> > > I thought I had this sorted this morning but it is still a problem.
> > >
> > > My application has a DataAccess Class.
> > >
> > > When it starts, it:
> > > Connects to a DB (OLE DB)
> > > If it connects it uses an OleDbCommand with an SQL String and the
> connection
> > > it has a DataAdapter with the command
> > > then it fills the DataSet's DataTable with the streamed data.
> > >
> > > It does this for 6 DataTables,
> > > then it closes the connection.
> > >
> > > That all works fine including saving the DataSet to an XML file and

if
> the
> > > connection to the DataBase is not successful, it reloads the last

know
> good
> > > DataSet from the pre-Saved XML.
> > >
> > > What I am trying to achieve is to periodically (once an hour or on
> demand )
> > > update 4 of the DataTables from the DataBase.
> > >
> > > The code for this is:
> > >
> > > ConnectMyDB() sub to connect to the Database
> > >
> > > If MyDBConnected Then
> > > If Not HasDownloaded Then
> > > 'Do the first download stuff
> > > Else
> > > daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
> > > daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
> > > daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
> > > daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
> > > End If
> > >
> > > This runs without error but the DataSet is not updated with any of

the
> > > changes that have occured at the DataBase.
> > >
> > > Am I missing something?
> > >
> > > Thanks Doug
> > >
> > >
> > >
>
>
>


Nov 21 '05 #7
Hi Doug,

I get the idea you are probably using the words "fill" and "update" in its
exact meaning in relation to each other.

Dataadapter.fil l(datatable) (should update) and fill a datatable in a
dataset from a database
Dataadapter.upd ate(ds, datatable) updates and fills a database from a
dataset datatable.

When you have autokeys, you can forget the first one for update, because the
old rows are not automaticly deleted. It does as well not add new database
rows added by others. So the most normal one would be the dataset.clear and
than that dataadapter.fil l

(Another approach can be to use timestamps in your database or /and maybe
where I think on now and never tried, use the negative seed from the autokey
and delete rows with a negative keynumber directly after the update.
However, in the last case you do not get new rows added by others than the
user).

However mostly in a small dataset is the fill that fast, that doing all
those difficult things would not be needed and you refresh the datast as I
wrote above after the update from the database.

I hope this helps?

Cor

"Doug Bell" <dug@bigpond>
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the
connection
it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the
connection to the DataBase is not successful, it reloads the last know
good
DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on
demand )
update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug

Nov 21 '05 #8
Cor thanks,

I thought initially that the update, although designed to update the
database with the Local User's changes (ie the DataSet) might also update
the Local DataSet with any changes that had occured to the DataBase; ie like
replication.

But I realise, now why that can not occur. I will have to use the Clear and
Fill and build some checks to get around any failures.

Thanks

Doug
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ep******** ******@TK2MSFTN GP09.phx.gbl...
Hi Doug,

I get the idea you are probably using the words "fill" and "update" in its exact meaning in relation to each other.

Dataadapter.fil l(datatable) (should update) and fill a datatable in a
dataset from a database
Dataadapter.upd ate(ds, datatable) updates and fills a database from a
dataset datatable.

When you have autokeys, you can forget the first one for update, because the old rows are not automaticly deleted. It does as well not add new database
rows added by others. So the most normal one would be the dataset.clear and than that dataadapter.fil l

(Another approach can be to use timestamps in your database or /and maybe
where I think on now and never tried, use the negative seed from the autokey and delete rows with a negative keynumber directly after the update.
However, in the last case you do not get new rows added by others than the
user).

However mostly in a small dataset is the fill that fast, that doing all
those difficult things would not be needed and you refresh the datast as I
wrote above after the update from the database.

I hope this helps?

Cor

"Doug Bell" <dug@bigpond>
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the
connection
it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the connection to the DataBase is not successful, it reloads the last know
good
DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on
demand )
update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug


Nov 21 '05 #9
Cor thanks,

I thought initially that the update, although designed to update the
database with the Local User's changes (ie the DataSet) might also update
the Local DataSet with any changes that had occured to the DataBase; ie like
replication.

But I realise, now why that can not occur. I will have to use the Clear and
Fill and build some checks to get around any failures.

Thanks

Doug
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ep******** ******@TK2MSFTN GP09.phx.gbl...
Hi Doug,

I get the idea you are probably using the words "fill" and "update" in its exact meaning in relation to each other.

Dataadapter.fil l(datatable) (should update) and fill a datatable in a
dataset from a database
Dataadapter.upd ate(ds, datatable) updates and fills a database from a
dataset datatable.

When you have autokeys, you can forget the first one for update, because the old rows are not automaticly deleted. It does as well not add new database
rows added by others. So the most normal one would be the dataset.clear and than that dataadapter.fil l

(Another approach can be to use timestamps in your database or /and maybe
where I think on now and never tried, use the negative seed from the autokey and delete rows with a negative keynumber directly after the update.
However, in the last case you do not get new rows added by others than the
user).

However mostly in a small dataset is the fill that fast, that doing all
those difficult things would not be needed and you refresh the datast as I
wrote above after the update from the database.

I hope this helps?

Cor

"Doug Bell" <dug@bigpond>
I thought I had this sorted this morning but it is still a problem.

My application has a DataAccess Class.

When it starts, it:
Connects to a DB (OLE DB)
If it connects it uses an OleDbCommand with an SQL String and the
connection
it has a DataAdapter with the command
then it fills the DataSet's DataTable with the streamed data.

It does this for 6 DataTables,
then it closes the connection.

That all works fine including saving the DataSet to an XML file and if the connection to the DataBase is not successful, it reloads the last know
good
DataSet from the pre-Saved XML.

What I am trying to achieve is to periodically (once an hour or on
demand )
update 4 of the DataTables from the DataBase.

The code for this is:

ConnectMyDB() sub to connect to the Database

If MyDBConnected Then
If Not HasDownloaded Then
'Do the first download stuff
Else
daMyTable1.Upda te (dsMyDataSet, "MyDataTabl e1")
daMyTable2.Upda te (dsMyDataSet, "MyDataTabl e2")
daMyTable3.Upda te (dsMyDataSet, "MyDataTabl e3")
daMyTable4.Upda te (dsMyDataSet, "MyDataTabl e4")
End If

This runs without error but the DataSet is not updated with any of the
changes that have occured at the DataBase.

Am I missing something?

Thanks Doug


Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1816
by: Ms.net | last post by:
I am having problem updating data with dataadapter....in some of my tables. I realize that, Dataadapter doesn't SOMETIME fire event rowupdating even if there are new rows. Because of that,rows are not updating in Databases. I use olecommandbuilder to generate Insert command. Update and Delete work but only new rows are not inserted.
1
1549
by: Ms.net | last post by:
am having problem updating data with dataadapter....in some of my tables. I realize that, Dataadapter doesn't SOMETIME fire event rowupdating even if there are new rows. Because of that,rows are not updating in Databases. I use olecommandbuilder to generate Insert command. Update and Delete work but only new rows are not inserted.
2
322
by: Ruslan Shlain | last post by:
Is there a way to tell DataAdapter to continue updating if it encounters error. So, in other words once it starts to update records in the database and it fails on one of them, then it would continue updating rest of the remaining records in the dataset.? Any suggestions or samples would be very helpful. Thank you all. -- Ruslan Shlain
3
8946
by: RSH | last post by:
Hi, I have a situation in where i have two instances of SQL server, the first is our Production Environment, the second is our Development environment. Both servers contain the same databases but I need to write a utility that can transfer a row of data from the Production to the Development servers. I wrote the code below, which doesn't error...but it doesn't work...no data is updated. This is very odd because I can see that both of...
2
13976
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
14010
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
5
5052
by: George | last post by:
I have set DataAdapter.AcceptChangesDuringUpdate = true; However, I find that I still need to call AcceptChanges on the associated DataTable, DataTable.AcceptChanges(); Has anyone encountered that? Am I not setting this field properly? The following are some of the snippets of the codes which may help explain
2
1179
by: mfleet1973 | last post by:
Hi Gang. I'm using VB.Net 2003. In the following code I'm updating the dataadapter with a new record added to the table: OleDbDataAdapter1.Update(DataSet11.GetChanges, "Table") However, when I add another record and update the dataadapter again, the first record gets added a second time. Is there something else that needs to be done after doing the update?
3
12533
by: Rich | last post by:
What is the diffeence bewtween a dataAdapter.InsertCommand and dataAdapter.SelectCommand (and dataAdapter.UpdateCommand for that matter)? Dim da As SqlDataAdapter conn.Open da.SelectCommand = New SqlCommand da.SelectCommand.Connectoin = conn da.SelectCommand.CommandType = Command.Text da.SelectCommand.CommandText = "insert Into tbl1 Select * from tbl2" da.SelectCommand.ExecuteNonQuery
0
9999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10983
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9684
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8048
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7206
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.