Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Weird Syntax Error

Weird Syntax Error

Scheduled Pinned Locked Moved Visual Basic
helpquestiondiscussionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kerry Drake
    wrote on last edited by
    #1

    I am trying to write a simple procedure to update a record in a data base using the following:

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    If m_dtEmployees.Rows.Count <> 0 Then
    m_dtEmployees.Rows(m_rowPosition)("Employee") = txtEmployeeName.Text
    m_dtEmployees.Rows(m_rowPosition)("Password") = txtPassword.Text
    m_daDataAdapter.Update(m_dtEmployees)
    End If
    End Sub
    End Class

    If I make a change to the txtEmployeeName textbox and hit save it works fine. If I make a change in the txtPassword text box I get a Syntax error in UPDATE statement error. I used the m_dtEmployees.Columns.Contains method to check to make sure it saw "Password" as a column and it does... Any thoughts?

    My goal in life is to be the kind of person my dog thinks I am.

    C A 2 Replies Last reply
    0
    • K Kerry Drake

      I am trying to write a simple procedure to update a record in a data base using the following:

      Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
      If m_dtEmployees.Rows.Count <> 0 Then
      m_dtEmployees.Rows(m_rowPosition)("Employee") = txtEmployeeName.Text
      m_dtEmployees.Rows(m_rowPosition)("Password") = txtPassword.Text
      m_daDataAdapter.Update(m_dtEmployees)
      End If
      End Sub
      End Class

      If I make a change to the txtEmployeeName textbox and hit save it works fine. If I make a change in the txtPassword text box I get a Syntax error in UPDATE statement error. I used the m_dtEmployees.Columns.Contains method to check to make sure it saw "Password" as a column and it does... Any thoughts?

      My goal in life is to be the kind of person my dog thinks I am.

      C Offline
      C Offline
      ctwalker
      wrote on last edited by
      #2

      By what you've posted I cant see anything that would be causing a problem. When I get errors like this I always look at the SQL command that is being executed. (Either by examining the Update command in the Adapter or by doing a trace on SQL and seeing what exactly is being executed. Try looking at that, and if you don't see anything wrong with the SQL, post it here and I'll check it out. Good luck.

      1 Reply Last reply
      0
      • K Kerry Drake

        I am trying to write a simple procedure to update a record in a data base using the following:

        Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If m_dtEmployees.Rows.Count <> 0 Then
        m_dtEmployees.Rows(m_rowPosition)("Employee") = txtEmployeeName.Text
        m_dtEmployees.Rows(m_rowPosition)("Password") = txtPassword.Text
        m_daDataAdapter.Update(m_dtEmployees)
        End If
        End Sub
        End Class

        If I make a change to the txtEmployeeName textbox and hit save it works fine. If I make a change in the txtPassword text box I get a Syntax error in UPDATE statement error. I used the m_dtEmployees.Columns.Contains method to check to make sure it saw "Password" as a column and it does... Any thoughts?

        My goal in life is to be the kind of person my dog thinks I am.

        A Offline
        A Offline
        AlexeiXX3
        wrote on last edited by
        #3

        Have you tried EndEdit for the datarow just before the m_daDataAdapter.Update(m_dtEmployees)?

        Alexei Rodriguez

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups