Loading

Syntax Error (missing operator) VB2005

1 post / 0 new
Offline
Joined: 02/28/2010
Syntax Error (missing operator) VB2005

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.

AttachmentSize
_0Error.jpg41.85 KB

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.