updating dataset when original data adapter has been disposed of.

G

Guest

Hello:

I have a separate module that creates my dataset and passes it back to my
form. I am using vb.net 2003 with ado.net and sql server 2000. The
dataadpator that creates the dataset using a stored procedure is disposed
right after the dataset is created.

Now I want to update that dataset (not one record at a time). I cannot just
use da.update(ds) because the data adator does not exist. If I just create
a new data adapter and do an update on the dataset, the changes are not
reflected in the table because this data adator knows nothing about the table
that the dataset was based upon. How can I use a new adapter to do this or
do I have to keep my original data adapter in memory, which means I cannot
separate my data gathering from my form.
 
G

Guest

You do not need the original dataadapter.

Create a connection object.
Create a command object referencing the connection.
On the command object, populate the commandtext and parameters collection.
Set the DataSet.UpdateCommand = the new command object
Create a DataAdapter Object.
Execute the DataAdapter.Update method, passing the dataset to it.
The dataAdapter will pickup on the attributes of the rows that have changed...

That's it, in pseudo-kinda-code...
 
G

Guest

One caveat. I am using a datagrid (componentone, but that should not
matter). But I do not have a commandtext for the updatecommand. Should that
matter?
 

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