Passing a string of concatenated strings to be used with ''IN'' operator in the query

  • How do you pass the string to the stored procedure? Via ADO Command Object?


    N 56°04'39.16"
    E 12°55'05.25"

  • yes,

     this is how i do it

    vstrSQL = "PS_SEARCH_MASTER_PRODUCT_TEST " & vstrDPCI     

    robjRS.CursorLocation = adUseClient

    robjRS.Open vstrSQL, cnRun.ConnectionString, adOpenStatic, adLockReadOnly

    vstrDPCI is the input parameter & PS_SEARCH_MASTER_PRODUCT_TEST is the stored procedure name and robjRS is ADO recordset

  • First learn about arrays and list queries at http://sommarskog.se/arrays-in-sql.html and then realize that you are sending a lot of parameters to the stored procedure, instead of the intended array.

    Remove all ' and put them only in front and after complete string, as this

    vstrDPCI = "'001000001,002050053,002050090,002050128,002050196,002050199,002050249,002051018,002051020,002051023,0020510'"

    vstrSQL = "PS_SEARCH_MASTER_PRODUCT_TEST " & vstrDPCI     

    robjRS.CursorLocation = adUseClient

    robjRS.Open vstrSQL, cnRun.ConnectionString, adOpenStatic, adLockReadOnly

     

     


    N 56°04'39.16"
    E 12°55'05.25"

  • Thanks Peter ..your hint and some additional stuff has helped me to work it out..

     

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply