How to reuse ado command parameter in a loop

I'm attempting to reassign the value of an ADO command parameter in a loop.  How is that done?  Here's what I've come up with that isn't working (note: we want to not find the trans_code in the database for it to be valid) :

if instr(1,x_transaction_code,",") then  'get the transaction code(s) into an array
	arr_transaction_code = split(x_transaction_code,",")
else
	arr_transaction_code(0) = x_transaction_code
end if

set sqlCommand = Server.CreateObject("adodb.command")
with sqlCommand
	.ActiveConnection = conn
	.CommandType = 1
	.CommandTimeout = 30
	.CommandText = "select top 1 AffTrackingParam from PromoOrder where AffTrackingParam = ?"
	.Parameters.Append(.CreateParameter("@AffTrackingParam", db_varchar, input_param, 150)) 'no value is assigned here
end with

for Each i in arr_transaction_code
	if len(i) = 20 or len(i) = 19 then
		sqlCommand.Parameters("@AffTrackingParam").value = i 'update the parameter value from the tc array
		set rs = sqlCommand.execute()
		if rs.eof then
			tcgood = true
		end if
	end if
	rs.close
	set rs = nothing
	set sqlCommand = nothing
next

Open in new window

RossaminoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I would place your recordset in a function like this

<%
function findTransCode(x)
' x = transcode
   '*********  PLEASE CREATE YOUR OWN CONNECTION AND RECORDSET ON THESE LINES ****
    'create database connection
    'sql= "select transCode from myTable where transCode = "&x ' if numeric
    ' create recordset rs
    '******************************************************************************
         if not rs.bof or not rs.eof then
             findTransCode="found"
             else
             findTransCode="not_found"
         end if

    'close recordset rs
end function

if instr(1,x_transaction_code,",") then  'get the transaction code(s) into an array
	arr_transaction_code = split(x_transaction_code,",")
else
	arr_transaction_code(0) = x_transaction_code
end if

for each iTransaction in arr_transaction_code

   response.write findTransCode(iTransaction)
next
%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RossaminoAuthor Commented:
This is what I ended up doing it worked super.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.