Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi There

I Have A Datagrid That I Use To Fill An Invoice With ItemID, Description,Qunty,Price.

 

Saving And Retrieving The Invoice to and from SQL Server Is POC

 

How Can I Mark The Modification On Each row Or a Deleted Row , So That When I Save My Work The Software Would Recognise The Update That Has Been Done And Perform The Condition Given Correctly

my Condition In My Code That I Have Assigned In The Save Mode Are

 

For Each row In InvDataSet1.Tables(0).Rows

'Assign Values To All Parameters And Excute Querry

With MyComm

.Parameters("@InvNum").Value = CInt(txtInvID.Text)

.Parameters("@ItemID").Value = row.Item(1)

.Parameters("@InvQunty").Value = row.Item(2)

.Parameters("@ItemPrice").Value = row.Item(3)

.Parameters("@InvVAT").Value = row.Item(4)

End With

If row.RowState = DataRowState.Added Then

MyComm.CommandText = "NewInvLine"

ElseIf row.RowState = DataRowState.Modified Then

MyComm.CommandText = "UpdateInvLine"

ElseIf row.RowState = DataRowState.Deleted Then

MyComm.CommandText = "DeleteInvLine"

ElseIf row.RowState = DataRowState.Unchanged Then

MyComm.CommandText = "UpdateInvLine"

End If

MyComm.ExecuteNonQuery()

[\Code]

Thank You In Advance

:confused:

Posted

Instead of all that messing around, why not just use a data adapter that has all commands assigned. Then a call to the Update method of data adapter will pick the correct command automatically AND set the RowState of your row.

 

If you want to stick to your current method, a quick look at the members of the DataRow class would have revealed the AcceptChanges method.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...