Updating vs Inserting

T

Tina

Below is pasted how I normally do an insert using a design time data adapter
and dataset in an

ASP.NET application. How can I least modify this code to do an update? (I
have all of the commands

generated in the data adapter)
Thanks,
T

Dim insertRow As dsPartNumsNew.PartNumbersRow
insertRow = DsPartNumsNew1.PartNumbers.NewRow()
insertRow.PP_Part_Num = tbPartNo.Text
insertRow.Description = tbDescription.Text
insertRow.Category = tbCategory.Text
insertRow.Manufacturer = tbManufacturer.Text
If tbPrice.Text.Trim = "" Then
insertRow._Price_ = 0
Else
insertRow._Price_ = tbPrice.Text
End If
insertRow.GL_Code = ddlGL.SelectedValue
insertRow.DeletedByUser = False
insertRow.TrackInventory = cbTrackInv.Checked
'add the row to the dataset...
Try
DsPartNumsNew1.PartNumbers.AddPartNumbersRow(insertRow)
daPartNumsNew.Update(DsPartNumsNew1)
Catch ex As SqlException
If ex.Number = 2627 Then
lblError.Text = "Part already exists"
Exit Sub
Else
lblError.Text = ex.Message
Exit Sub
End If
End Try
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top