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. simple solution but for the life of me I cannot figure it out.

simple solution but for the life of me I cannot figure it out.

Scheduled Pinned Locked Moved Visual Basic
databasesql-servercomsysadminhelp
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.
  • M Offline
    M Offline
    markmyb
    wrote on last edited by
    #1

    Here is a SQL string I am execute with an ADO connecion object. objAdoCon.Execute "insert into MEQUERY " _ & "(MESystemListCode, MEQueryName , MESystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, MEStoreProc) " _ & "values " _ & "(" & cboSystem.ItemData(cboSystem.ListIndex) & ", " _ & "'Profile', " _ & "'" & Trim$(txtQuery.Text) & "', " _ & "'" & Trim$(txtSelect.Text) & "', " _ & "'" & Trim$(txtFrom.Text) & "', " _ & "'" & Trim$(txtWhere.Text) & "', '" _ & Trim$(txtOrderBy.Text) & "', '" _ & Trim$(txtStoredProc.Text) & "')" Here is the result of this query.. objADOCon.Execute "insert into MEQUERY (MESystemListCode, MEQueryName , " _ & "SystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, " _ & "MEStoreProc) " _ & "values " _ & "(3, 'Profile', 'Merchant Search', 'merchant', 'merchants', " _ & "'merchant like '%Bob%'', 'merchant', ''):confused: give this error: Error #: -2147217900 Error Desc: Line 1: Incorrect syntax near '%Bob%'. Error Source: Microsoft OLE DB Provider for SQL Server How can I execute this proc with out having the '' in the query... Latter:cool: Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."

    A 1 Reply Last reply
    0
    • M markmyb

      Here is a SQL string I am execute with an ADO connecion object. objAdoCon.Execute "insert into MEQUERY " _ & "(MESystemListCode, MEQueryName , MESystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, MEStoreProc) " _ & "values " _ & "(" & cboSystem.ItemData(cboSystem.ListIndex) & ", " _ & "'Profile', " _ & "'" & Trim$(txtQuery.Text) & "', " _ & "'" & Trim$(txtSelect.Text) & "', " _ & "'" & Trim$(txtFrom.Text) & "', " _ & "'" & Trim$(txtWhere.Text) & "', '" _ & Trim$(txtOrderBy.Text) & "', '" _ & Trim$(txtStoredProc.Text) & "')" Here is the result of this query.. objADOCon.Execute "insert into MEQUERY (MESystemListCode, MEQueryName , " _ & "SystemListDesc, MESelect, MEFrom, MEWhere, MEDefaultOrder, " _ & "MEStoreProc) " _ & "values " _ & "(3, 'Profile', 'Merchant Search', 'merchant', 'merchants', " _ & "'merchant like '%Bob%'', 'merchant', ''):confused: give this error: Error #: -2147217900 Error Desc: Line 1: Incorrect syntax near '%Bob%'. Error Source: Microsoft OLE DB Provider for SQL Server How can I execute this proc with out having the '' in the query... Latter:cool: Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."

      A Offline
      A Offline
      AndyG
      wrote on last edited by
      #2

      'merchant like '%Bob'' needs to look like this: 'merchange like ''%Bob''' Basically you want to check all your textboxes for single quotes and replace any single quotes with two single quotes. You could also try making this a stored procedure and using an ADO command object, it *might* make things easier but I'm not guaranteeing anything. Good luck! Andy Gaskell, MCSD

      M 1 Reply Last reply
      0
      • A AndyG

        'merchant like '%Bob'' needs to look like this: 'merchange like ''%Bob''' Basically you want to check all your textboxes for single quotes and replace any single quotes with two single quotes. You could also try making this a stored procedure and using an ADO command object, it *might* make things easier but I'm not guaranteeing anything. Good luck! Andy Gaskell, MCSD

        M Offline
        M Offline
        markmyb
        wrote on last edited by
        #3

        Thanks Andy, Worked great. latter ;) Confusios say "Man who run in front of car get tired, Man who run behind car get exhausted."

        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