Results 1 to 4 of 4

Thread: Error using command.ExecuteNonQuery [resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    Savannah, GA
    Posts
    100

    Error using command.ExecuteNonQuery [resolved]

    I recieve an error that says: "Syntax error in UPDATE statment" when executing the following code.

    VB Code:
    1. Dim strConn As String
    2.         Dim strSQL As String
    3.         Dim connection As New OleDb.OleDbConnection
    4.  
    5.         strConn = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\inetpub\wwwroot\Webapplication1\isi.mdb"
    6.  
    7.         strSQL = "UPDATE keygenerator SET Section = 'H'  WHERE RNDID = '" & ModGlobal.key & "'"
    8.  
    9.         connection.ConnectionString = strConn
    10.         connection.Open()
    11.  
    12.         Dim command As New OleDb.OleDbCommand
    13.         command.CommandText = strSQL
    14.  
    15.         command.Connection = connection
    16.  
    17.         Try
    18.  
    19.             command.ExecuteNonQuery()
    20.         Catch ex As OleDb.OleDbException
    21.             ASPNET_MsgBox(ex.Message)
    22.         End Try

    I have tested the actual SQL statement that is generated in this code using my database and it runs fine so the error shouldn't be an SQL issue. I usually program windows apps and this is my first ASP.NET web app. Is this method of executing a nonquery legal in a webapp? Any help is appreciated. thanks in advance.
    Last edited by ERage; Jan 16th, 2004 at 10:02 AM.

  2. #2
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    the syntax looks fine to me... what kind of dbtype is the key value? Is it possible it is a number field and you use ' ' around it?

    perhaps someone else with sharper eyes than me can find any other problems?

    kind regards
    Henrik

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    Savannah, GA
    Posts
    100
    Unfortunately both fields used in the query are stored as text in the DB (for the purpose of keeping leading zeros on the RNDID number).

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Location
    Savannah, GA
    Posts
    100
    I think I got it, I changed section to another term and it worked
    fine. possibly a keyword? anyways, thanks for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width