Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Use Access to Call a stored Procedure
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 06/05/2013 :  22:41:21  Show Profile  Reply with Quote
See code below.

This runs, but I would like to call the same SP 4 times passing new parameters each time. Do I have to drop the parameters and add new one? Can I change the value in a existing parameter? Do I have to drop the cmd and write a new one. I would like to use the most efficient method.

Thanks, Mike

Dim intTest As Integer
Dim cmd As New ADODB.Command
Dim cnn As New ADODB.Connection
Dim prmID As New ADODB.Parameter

With cnn
.Provider = "SQLOLEDB"
.ConnectionString = "data source=XXXXXXXX-PC;initial catalog=ProdDB;Trusted_Connection=Yes"
End With

With prmID
.Name = "Return"
.Type = adInteger
.Direction = adParamReturnValue
End With

With cmd
.Parameters.Append prmID

.Parameters.Append .CreateParameter("@Session", adInteger, adParamInput, , 3)
.Parameters.Append .CreateParameter("@Vessel", adInteger, adParamInput, , 3)
.Parameters.Append .CreateParameter("@Position", adVarChar, adParamInput, 5, "Lead")
.Parameters.Append .CreateParameter("@Pressure", adVarChar, adParamInput, 5, "H")

.ActiveConnection = cnn
.CommandText = "usp_CalcPart"
.CommandType = adCmdStoredProc
intTest = .Parameters("Return")

End With



5072 Posts

Posted - 06/06/2013 :  10:38:16  Show Profile  Visit russell's Homepage  Reply with Quote
Make it a function that accepts 4 arguments: intSession, intVessel, strPosition, strPressure.

then these lines will look like:

.Parameters.Append .CreateParameter("@Session", adInteger, adParamInput, , cint(intSession))
.Parameters.Append .CreateParameter("@Vessel", adInteger, adParamInput, , cint(intVessel))
.Parameters.Append .CreateParameter("@Position", adVarChar, adParamInput, 5, cstr(strPosition))
.Parameters.Append .CreateParameter("@Pressure", adVarChar, adParamInput, 5, cstr(strPressure))
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000