Hi there, I have the exact same frustration except with webforms....
http://www.15seconds.com/issue/030604.htm
I found this hope it helps a bit! Also download the visual basic .net
resource kit it has some examples exactly for what your talking about as
well.
Private Sub UpdateProduct()
' This sub is used to update and existing record with values
' from the form.
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim strSQL As String
Dim intRowsAffected As Integer
' Validate form values.
If Not IsValidForm() Then
Exit Sub
End If
Try
' Build update statement to update product table with data
' on form.
strSQL = "UPDATE Products SET" & _
" ProductName = " & PrepareStr(txtProductName.Text) & _
" ,QuantityPerUnit = " & PrepareStr(txtQtyPerUnit.Text) & _
" ,UnitPrice = " & txtUnitPrice.Text & _
" ,UnitsInStock = " & txtUnitsInStock.Text & _
" ,UnitsOnOrder = " & txtUnitsOnOrder.Text & _
" ,ReorderLevel = " & txtReorderLevel.Text & _
" ,SupplierID = " & CType(cbSuppliers.Items(cbSuppliers.SelectedIndex),
ListItem).ID & _
" ,CategoryID = " & CType(cbCategories.Items(cbCategories.SelectedIndex),
ListItem).ID & _
" ,Discontinued = " & CType(IIf(chkDiscontinued.Checked, "1", "0"), String)
& " " & _
"WHERE ProductID = " & CInt(txtProductID.Text)
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
intRowsAffected = cmSQL.ExecuteNonQuery()
If intRowsAffected <> 1 Then
MsgBox("Update Failed.", MsgBoxStyle.Critical, "Update")
End If
' Close and Clean up objects
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
Catch e As SqlException
MsgBox(e.Message, MsgBoxStyle.Critical, "SQL Error")
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRefresh.Click
PopulateCategoryCombo()
PopulateSupplierCombo()
PopulateProductList()
End Sub