Microsoft
Software
Hardware
Network
Question : Run same stored procedure iterating thru parameters
I am writing an Access app that needs to run a stored procedure (in SQL Server) several times while iterating thru a list of different values for the same parameter.
What I want to do is something like:
strConn = "dsn=CSO_APP;uid=crm_sql_a
dmin;pwd=a
dmin"
Set Conn = New ADODB.Connection
Conn.Open strConn
Set cmd = New ADODB.Command
cmd.CommandText = "dbo.CreateEffectivePriceC
omparisonT
able_sp"
cmd.CommandType = adCmdStoredProc
cmd.ActiveConnection = Conn
For Each CustNum in CustNums
cmd.Parameters.Append cmd.CreateParameter _
("CID", adChar, adParamInput, 10, CustNum)
Set rstEffectivePrice = cmd.Execute
'Do some work with the recordset
rstEffectivePrice.Close
Next
This works the first time thru but not any consecutive time.
What am I doing wrong?
Answer : Run same stored procedure iterating thru parameters
You need to incorporate a recordset loop (Do While Not (rs Is Nothing)) in your code. Your For/Next loop should be inside the recordset loop. See the example in the link I gave you.
Random Solutions
How to correct a 3021 error?
Exchange Server requirements
Can't activate Windows XP
Are there any FREE or low cost HTML, XML Development or Design Tools out there
Does any one know how can I make partition from HP7700 Small form factor?I tried do the way from disk management but mostof the option greyed ,only properties is active .
how in .net C# can you determine file type?
Unable to relay CRM email
How and when do you use AutoPostBack?
insert each word of a line of text into an element of an array
Periodic error in SSMS SQL Server 2008 R2