|
-
Nov 22nd, 2002, 07:18 AM
#1
Thread Starter
Frenzied Member
How to use parameter in "Where ...IN..." clause.
How can i use parameter in "Where...IN... Clause" ?
Consider this:
Select ID from tb1 where ID IN (1,5,7,9)
I want to use the part '1,5,7,9' as a parameter, but I dont know how. I tried to use this 'Select ID from tb2 where ID IN (?) ' in Data Adapter Configuration Wizard but i get the following error:
"OleDbCommand.Prepare method requires parameters of type '14' have an explicitly set Precision and Scale."
Any Idea?
-
Nov 22nd, 2002, 09:26 AM
#2
Addicted Member
You could pass the ID's in as a varchar parameter. In the database you could then split the value using a delimiter and convert that value to an int. Then build your query. This is my stripped down version in SQL Server to give you an idea.
CREATE PROCEDURE Prop_UpdatePropManager(
@Reg_Array Varchar(2000)
) AS
BEGIN
SELECT @nLen = Len(@Reg_Array)
SELECT @nCnt = 1
WHILE (@nCnt <= @nLen) BEGIN
SELECT @sTmp = SUBSTRING(@Reg_Array,@nCnt,1)
IF @sTmp = '|' BEGIN
**** CODE HERE TO CONVERT TO ********
CONVERT(Int,@sitem) etc etc
END ELSE BEGIN
SELECT @sItem = @sItem + @sTmp
END
SELECT @nCnt = @nCnt + 1
END
END
Wind and waves resolves all problems.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|