I have my fields set up in my .mdb as follows:
Number - (Autonumber)
Product
Todays Date
Date Created
Product Lifetime
The date fields are NOT set up as dates for right now, I wanted to make sure everything else was working ok.
I'm dealing with updating the fields with a combobox that allows the user to select which record they want to edit. The code for the combo box is:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
ds.Tables(0).PrimaryKey = New DataColumn() {ds.Tables(0).Columns("Number")}
Dim row As DataRow
row = ds.Tables(0).Rows.Find(ComboBox1.Text)
txtNumber.Text = row("Number")
txtProduct.Text = row("Product")
txtTodaysDate.Text = row("Todays Date")
txtDateCreated.Text = row("Date Created")
txtProductLifetime.Text = row("Product Lifetime")
txtNumber.ReadOnly = True
btnClear.Enabled = False
btnAdd.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
The code containing the error is contained in this block of code for "btnEdit"
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
Try
Dim com As New OleDbCommand
com.Connection = con
com.CommandText = "UPDATE ProductInfo SET [Product]='" & txtProduct.Text & _
"',[Todays Date]='" & txtTodaysDate.Text & "',[Date Created]='" & _
txtDateCreated.Text & "',[Product Lifetime]=" & txtProductLifetime.Text & _
"Where [Number]=" & ComboBox1.Text
com.ExecuteNonQuery()
MsgBox("Record Updated!")
KS_Connect()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
I have included a .jpg showing the exact error... I would appreciate any help very much!!! Thanks.
- 3 views