SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    May 2006
    Location
    USA
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Syntax to pass string in SQL Query

    I am trying to pass a String parameter in the SQL query , but getting a syntax error. Below is my code . Can you please and let me the right format for the same .

    Set objConnection = CreateObject("ADODB.Connection")
    wait(1)
    Set objRecordset = CreateObject("ADODB.Recordset")
    wait(1)
    objConnection.Open " DRIVER={Sybase ASE 12.5 ODBC Driver};UID=imdbo;DB=demand_ny;NA=gfidb104d.nam.ns root.net,44120;FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\Gstar.dsn;PWD=screwy"
    wait(1)
    objRecordset.CursorLocation = adUseClient
    wait(1)
    objRecordset.CursorType = adopenstatic
    wait(1)
    objRecordset.LockType = adlockoptimistic
    wait(1)
    ObjRecordset.Source="SELECT sector_id FROM dbo.contra_code where contra_mnem ="@Custome_menm
    wait(1)
    ObjRecordset.ActiveConnection=ObjConnection
    wait(1)
    ObjRecordset.Open 'This will execute your Query
    wait(1)
    If ObjRecordset.recordcount>0 then
    wait(1)
    Sector_ID = ObjRecordset("sector_id").Value
    Sector_ID = Cint (Sector_ID )
    wait(1)
    msgbox(Sector_ID )
    wait(1)
    End if

    objRecordset.Close

    objConnection.Close

  2. #2
    Senior Member
    Join Date
    Feb 2007
    Location
    Pittsburgh, USA
    Posts
    429
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Syntax to pass string in SQL Query

    ObjRecordset.Source="SELECT sector_id FROM dbo.contra_code where contra_mnem ='"&Custome_menm&"'"
    -Reddy

  3. #3
    Junior Member
    Join Date
    May 2006
    Location
    USA
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Syntax to pass string in SQL Query

    Thanks Tmreddy ..This works ..

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:11 AM.

Copyright BetaSoft Inc.