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
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB.NET 2005 ODBCCommand

VB.NET 2005 ODBCCommand

Scheduled Pinned Locked Moved Visual Basic
questionannouncementcsharpdatabase
3 Posts 2 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.
  • R Offline
    R Offline
    rahvyn6
    wrote on last edited by
    #1

    Hi All; I'm writing a small app that is displaying information in a datagridview from a FoxPro table. I am having issues on the update side of things. I am trying to write my own update statements using the ODBCCommand object, and parameters. However, the statement is failing, with only the message of Syntax Error. When I try to get the actual command text, it shows the sql statement with the @VarName placeholders. Is there anyway to get the final sql statement? Or should it show as the command text, and I am setting this up wrong. Here is what I am doing: sql = "UPDATE table1 SET Descript = @Desc " sql += "WHERE RefNum = @RefNum " cmd.CommandText = sql parm = New OdbcParameter("@desc", SqlDbType.Char, 120) parm.Value = oRow.Item("description").ToString().Trim() cmd.Parameters.Add(parm) parm = New OdbcParameter("@refnum", SqlDbType.Char, 12) parm.Value = oRow.Item("ref num").ToString().Trim() cmd.Parameters.Add(parm) cmd.ExecuteNonQuery() 'This fails with Syntax Error This is a shortened version, there are around 15 variables I am using. When I check the value of CommandText, it shows as: "UPDATE table1 sET Descript = @Desc WHERE RefNum = @RefNum" I am guessing this is what it should show, but is there anyway to see what is actually being sent to execute? Thanks

    K 1 Reply Last reply
    0
    • R rahvyn6

      Hi All; I'm writing a small app that is displaying information in a datagridview from a FoxPro table. I am having issues on the update side of things. I am trying to write my own update statements using the ODBCCommand object, and parameters. However, the statement is failing, with only the message of Syntax Error. When I try to get the actual command text, it shows the sql statement with the @VarName placeholders. Is there anyway to get the final sql statement? Or should it show as the command text, and I am setting this up wrong. Here is what I am doing: sql = "UPDATE table1 SET Descript = @Desc " sql += "WHERE RefNum = @RefNum " cmd.CommandText = sql parm = New OdbcParameter("@desc", SqlDbType.Char, 120) parm.Value = oRow.Item("description").ToString().Trim() cmd.Parameters.Add(parm) parm = New OdbcParameter("@refnum", SqlDbType.Char, 12) parm.Value = oRow.Item("ref num").ToString().Trim() cmd.Parameters.Add(parm) cmd.ExecuteNonQuery() 'This fails with Syntax Error This is a shortened version, there are around 15 variables I am using. When I check the value of CommandText, it shows as: "UPDATE table1 sET Descript = @Desc WHERE RefNum = @RefNum" I am guessing this is what it should show, but is there anyway to see what is actually being sent to execute? Thanks

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      Whenever I've used parameters, I've always had to do a cmd.DeriveParameters before I could set the parameters value...I'm not sure if it is a required call but you may want to look into it. Also, I do not believe there is a way during debugging to see what the actual statement being sent is. You could try putting in a try-catch block and quickwatching the exception, it may have more detailed error messages. Hope this helps.

      R 1 Reply Last reply
      0
      • K Kschuler

        Whenever I've used parameters, I've always had to do a cmd.DeriveParameters before I could set the parameters value...I'm not sure if it is a required call but you may want to look into it. Also, I do not believe there is a way during debugging to see what the actual statement being sent is. You could try putting in a try-catch block and quickwatching the exception, it may have more detailed error messages. Hope this helps.

        R Offline
        R Offline
        rahvyn6
        wrote on last edited by
        #3

        I dont think that cmd.DeriveParameters is a valid statement in vb.net, at least not for an OdbcCommand. I thought about the try-catch, just reports the same error, "Syntax Error". I really hate FoxPro...

        And now, adding color, a group of anonymous Latin American meat packing glitterati

        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