Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass a parameter to SQL Stored Procedure from Visual basic?

Status
Not open for further replies.

ii128

Programmer
May 18, 2001
129
US

How to pass a parameter to SQL Stored Procedure from Visual basic?
 
Use command objects:

Set oCmd = New ADODB.Command
With oCmd
.NamedParameters = True
.CommandType = adCmdStoredProc
.CommandText = "uspDeleteSavedCriteria"
.Parameters.Append .CreateParameter("xuSavedCriteriaUID", adGUID, adParamInput, , msSavedCriteriaUID)
.ActiveConnection = xoConn
.Execute
End With

The namedparameters property is new with ado 2.6 and speeds up stored proc calls if you know how to build the parameters for the call. If you don't you can try this:

Set oCmd = New ADODB.Command
With oCmd
.ActiveConnection = xoConn
.CommandType = adCmdStoredProc
.CommandText = "uspDeleteSavedCriteria"
.Parameters.Refresh
.Parameters("xuSavedCriteriaUID").value = msSavedCriteriaUID
.Execute
End With

But it takes an extra trip to the database to fill the parameters collection for you (=Slower).

Hope this helps. -Chris Didion
Matrix Automation, MCP
 
But How can I pass the parameter through data Environment?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top