For dataset after Inert, Update. How to reflect fields output by store proc ?

R

Rabbit

Dear all,

After updating the changes in dataset onto database thru the dataAdapter, if
the UpdateCmd of the dataAdapter is based on parameters store proc which
return a field called "LastUpdatedDate". Can it be updated onto the dataset?

=========== part of my code as follows ===========
Dim SelectCmd As New SqlCommand(SP_CUSTOMER_GET_ALL, conn)
SelectCmd.CommandType = CommandType.StoredProcedure

Dim UpdateCmd As New SqlCommand(SP_CUSTOMER_UPDATE, conn)
UpdateCmd.CommandType = CommandType.StoredProcedure
With UpdateCmd.Parameters
.Add("@LastUpdatedDate", SqlDbType.DateTime).Direction =
ParameterDirection.Output
.Add("@CustomerID", SqlDbType.Char, 7, "CustomerID")
.Add("@Name", SqlDbType.NVarChar, 15, "Name")
End With

da = New SqlDataAdapter
da.SelectCommand = SelectCmd
da.UpdateCommand = UpdateCmd

Dim ds As New DataSet
da.Fill(ds, "tbl_Customer")
=================================

Is there a way to return those output information back to dataset thru the
dataAdapter on the Update process? so that it can save one more trip to
requery the database to reflect the changes.

Thanks in advance!
 
R

Rajesh Patel

you will get output parameters automatically back with the values in the
vb.net when you call dataadapter update method.

just you need to set output parametr's value in the stored procedure.

Rajesh Patel
 
R

Rabbit

Rajesh Patel

Thanks! What a silly mistake I made on the missed column name when I define
the output parameter.

Cheers
 
R

Rabbit

I fixed the problem, it was because I missed to assign a "Column name" on
specifying the output parameter!

Thanks anyway!
 

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