wahoud Posted June 21, 2005 Posted June 21, 2005 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: Quote
jmcilhinney Posted June 22, 2005 Posted June 22, 2005 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.