Create Update DS

  • Thread starter Thread starter Ornette
  • Start date Start date
O

Ornette

Hello,

I have a stored procedure which generates some values in the table.
When I use update() how to populate the dataset with theses values ?

For the moment I use output parameter but it just works for 1 row and as the
dataset doesn't have the value I should put it after and the rowstate goes
to "modified"...

Any ideas ?

SIncerly,
 
I don't understand what you mean.

Does your stored procedure generate values in the table in SQLServer? Or
are you trying to write data to the table in SQLServer? Or do you have data
in the table in SQLServer, and are trying to read it?

Robin S.
 
Ok, sorry it was not so clear.

I have an update sotred procedure wich generates values in SQL Server.
I replaced the output parameted with a Select ... @@Identity at the end of
the procedure.
It seems ok, but I don't know what exaclty will happen when I will send an
entire dataset with multiples row added, modified and deleted to the
Update() function (which calls Insert, Update and Delete stored
procedures)...

Ornette.
 
I don't know how you're doing your updates, or what your SP looks like.

If you have a DataSet and are submitting the updates using a DataAdapter,
it iterates through the rows and performs each update/delete/insert as
needed, so it should retrieve the updated identity column value as it goes.

Robin S.
---------------------------
 
Hello,

(for info only)

My Create SP uses the auto id (generated bu sql server) combined with dates
and other tables contents to generate sort of "Custom Guid".
My Update SP generates date of modification and other parameters generated
from other tables.

I use a DataAdapter and it works as you said, except I need to put "Select
columns from table where id=@@identity" at the end for the dataset to be
filled with these generated values. If I don't add this select statement at
the end of the SP, the generated columns in database are not copied in the
dataset (that's normal).

Thank you for your comments.
 
Oh, I see, you're talking about regenerating all of your columns. I don't
see why it wouldn't work. You've gotten it to work now?

Robin S.
----------------------------------------
 
Robin,

Yes it works great !
My only "problem" is that I don't know if the select (at the end of Update
SP and Create SP) is called for each row, or at the end for everything,
or...? because I don't know howUpdate() method of DataAdapter calls SQL
Server (create a DS for update, create a DS for Insert then combine it ?).

I will try to see it with the SQL profiler
 
The Update method of the DataAdapter calls SQLServer one row at a time. It
checks the RowState; if it's an insert, it uses the InsertCommand; if it's
an update, it uses the Update Command, and so on. So you should be okay.

Robin S.
----------------------------
 
Back
Top