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?
 
Generally...

1. Create an ADO connection to the SQL Server database.
2. Create an ADO Command object
a. Point the ADO command object at the ADO connection
b. Set the type of ADO command object to stored proc
c. Set the stored proc name of the command object to the name of stored proc
d. Set the parameters of the command object
3. Execute the ADO command object

As in:

Set adoConn = New ADODB.Connection
adoConn.open "parameters to open db here"
Set adoCmd = New ADODB.Command
adoCmd.ActiveConnection = adoConn
adoCmd.CommandType = adCmdStoredProc
adoCmd.CommandText = "sp_mystoredproc"
set adoParam = New ADODB.Parameter
adoParam.Direction = adParamInput
adoParam.Value = "value of param to pass"
adoCmd.Parameters.Append adoParam
... (more params as necessary)
adoCmd.Execute
 
But, How can I pass the parameter through data environment?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top