July 11, 2006 at 11:35 am
hi,
I have a situation where i need to pass concatenated string ex:
'002050053','002050090','002050128','002050196','002050199','002050249','002051018','002051020','002051023','002051076'
which want to pass to the stored procedure so as to use it with 'IN' operator in the query. I'm formatting this this string in VB 6.0 . In front end i format it as
vstrDPCI = Chr(34) & "'002050053','002050090','002050128','002050196','002050199','002050249','002051018','002051020','002051023','002051076'" & Chr(34)
and pass it to the Stored procedure. This works fine as long as the lenght is less than 128, if it exceeds 128 i get this error
[Microsoft][ODBC SQL Server Driver][SQL Server]The identifier that starts with ''001000001','002050053','002050090','002050128','002050196','002050199','002050249','002051018','002051020','002051023','0020510' is too long. Maximum length is 128.
In the stored procedure this parameter is defined as varchar(8000).
Can anyone help me out..
July 11, 2006 at 12:01 pm
How do you pass the string to the stored procedure? Via ADO Command Object?
N 56°04'39.16"
E 12°55'05.25"
July 11, 2006 at 12:06 pm
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
July 11, 2006 at 1:50 pm
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"
July 11, 2006 at 3:27 pm
Thanks Peter ..your hint and some additional stuff has helped me to work it out..
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply