E
Eph0nk
Hi,
I have a datagrid in a winform that lets users input "detail lines" of an order form. I manually create both the dataset and the datagrid (ie: to have dropdownboxes etc) - but because of this the sqlCommandBuilder seems to be unable to create the update and insert commands - so I have to make them manually.
This is what I have thusfar, but my problem is that it only updates the first row that got changed with the new value.. So if I update one row, it seems to work, but I'm unable to update multiple lines at once. Any idea's? Or am I taking the complete wrong approach to this?
Dim objRow As DataRow
For Each objRow In ds.Tables("Details").Rows
If objRow.RowState = DataRowState.Modified Then
Dim strUpdate As String
strUpdate = "UPDATE Details SET Aantal = @Aantal where Detailnr = @Detailnr"
da.UpdateCommand = New SqlCommand(strUpdate, sqlConn)
da.UpdateCommand.Parameters.Add(New SqlParameter("@Detailnr", SqlDbType.Int))
da.UpdateCommand.Parameters("@Detailnr").Value = objRow("Detailnr")
da.UpdateCommand.Parameters.Add(New SqlParameter("@Aantal", SqlDbType.Int))
da.UpdateCommand.Parameters("@Aantal").Value = objRow("Aantal")
'Debug.WriteLine(objRow("Detailnr").ToString())
da.Update(ds, "Details")
End If
Next
Thanks in advance for looking into this,
Tim De Vogel
S-Data NV
I have a datagrid in a winform that lets users input "detail lines" of an order form. I manually create both the dataset and the datagrid (ie: to have dropdownboxes etc) - but because of this the sqlCommandBuilder seems to be unable to create the update and insert commands - so I have to make them manually.
This is what I have thusfar, but my problem is that it only updates the first row that got changed with the new value.. So if I update one row, it seems to work, but I'm unable to update multiple lines at once. Any idea's? Or am I taking the complete wrong approach to this?
Dim objRow As DataRow
For Each objRow In ds.Tables("Details").Rows
If objRow.RowState = DataRowState.Modified Then
Dim strUpdate As String
strUpdate = "UPDATE Details SET Aantal = @Aantal where Detailnr = @Detailnr"
da.UpdateCommand = New SqlCommand(strUpdate, sqlConn)
da.UpdateCommand.Parameters.Add(New SqlParameter("@Detailnr", SqlDbType.Int))
da.UpdateCommand.Parameters("@Detailnr").Value = objRow("Detailnr")
da.UpdateCommand.Parameters.Add(New SqlParameter("@Aantal", SqlDbType.Int))
da.UpdateCommand.Parameters("@Aantal").Value = objRow("Aantal")
'Debug.WriteLine(objRow("Detailnr").ToString())
da.Update(ds, "Details")
End If
Next
Thanks in advance for looking into this,
Tim De Vogel
S-Data NV