SQL concatenation inside a vbscript

I have a problem with a SQL concatenation used in VB script.

I'm trying to contatenate a variable inside a SQL request but whatever the concatenation method i use, it fails !

Here is my code

dim nbr3Eu as integer = 6
dim waa2Eu as string

waa2Eu = "" _
& "SELECT riblib" _
& "      ," & nbr3Eu _
& "  FROM PCH" _
& "  WHERE RibPaysNuf <> 'NufSocPaysMU'" _
& "    AND PchID in " & XPchID _
& "  GROUP BY DevCode"

I've tried it with the PLUS sign concatenation but i still have the same result

dim nbr3Eu as integer = 6
dim waa2Eu as string

waa2Eu = "" _
+ "SELECT riblib" _
+ "      ," + nbr3Eu _
+ "  FROM PCH" _
+ "  WHERE RibPaysNuf <> 'NufSocPaysMU'" _
+ "    AND PchID in " + XPchID _
+ "  GROUP BY DevCode"

Need help, THANKS

Upvotes: 0

Views: 241

Answers (1)

schlebe
schlebe

Reputation: 3735

You must concatenate String, try replacing & nbr3Eu by & CStr(nbr3Eu)

Upvotes: 3

Related Questions