locked
what is wrong with this query which is used directly in vb RRS feed

  • Question

  • User702049738 posted

    I would just like to know whether the syntax is right for this particular query which is being used directly in VB.

    query = "SELECT r.ID " & _
    "FROM table_one r, ZONE_ORDER w " & _
    "WHERE w.Z_ID = CONCAT('VMA', REPLACE(r.ID, '-', '')) " & _
    "AND w.SWING_ID ='0' AND w.BUB_ID='0' " & _
    "AND r.ID not in ('999-543', '999-168', '999-362', '999-304') "


     

    Wednesday, August 11, 2010 11:16 AM

Answers

  • User1224194097 posted

    try this way

    Query = "SELECT r.ID " & _
                                "FROM table_one r, ZONE_ORDER w " + _
                                "WHERE w.Z_ID =" + String.Concat("VMA", Replace(r.ID, "-", "")) + _
                                "AND w.SWING_ID =0 AND w.BUB_ID=0 " + _
                                "AND r.ID not in ('999-543', '999-168', '999-362', '999-304') "


    I think Concat should be String.Concat.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 11, 2010 11:34 AM

All replies

  • User1224194097 posted

    try this way

    Query = "SELECT r.ID " & _
                                "FROM table_one r, ZONE_ORDER w " + _
                                "WHERE w.Z_ID =" + String.Concat("VMA", Replace(r.ID, "-", "")) + _
                                "AND w.SWING_ID =0 AND w.BUB_ID=0 " + _
                                "AND r.ID not in ('999-543', '999-168', '999-362', '999-304') "


    I think Concat should be String.Concat.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 11, 2010 11:34 AM
  • User3690988 posted

    Are you hitting a SQL DataBase?  If so, I don't think it will like the CONCAT (unless it's a user function in your database).  If it is SQL Server, and you don't have a CONCAT function then changing CONCAT('VMA', REPLACE(r.ID, '-', '')) to 'VMA' + REPLACE(r.ID, '-', '') might work.


    Wednesday, August 11, 2010 11:37 AM