SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

MikeBeck
Starting Member

USA
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"
.Open
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
.Execute
intTest = .Parameters("Return")

End With

cnn.Close

russell
Pyro-ma-ni-yak

USA
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  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000