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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Procedure syntax

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
GB
What is the syntax to refer to the Value selected in a combo box in an Access 2000 Form, in the WHERE command of a stored procedure.<br>
<br>
Thanks in advance,<br>
<br>
Simon
 
First you need to place your value in a variable in access. Then you need to execute your sp - something like:<br>
<br>
Dim adoCon = ADODB.Connection;<br>
Dim adoComm = ADODB.Command;<br>
Dim strVal as String;<br>
<br>
Set adoCon = new ADODB.Connection;<br>
Set adoComm = new ADODB.Command;<br>
<br>
'You now need to initialise your connection string<br>
..........<br>
<br>
strVal = &quot;EXEC SP_NAME ' & cmbCombo.Value & &quot;'&quot;;<br>
<br>
With adoComm<br>
.ActiveConnection = adoCon<br>
.CommandType = adStoredProcedure 'Check this from drop down<br>
.Text = strVal<br>
.Execute<br>
End With<br>
<br>
You need to check some of the sytax above (I don't have access to VB at the moment. However this will give you an idea.<br>
<br>
Cal<br>

 
The data you want isn't available to the stored procedure when it runs.&nbsp;&nbsp;It has to be passed as a parameter (or included in the SQL Source.)<br>ADO has support for parameters, so you don't have to build the string.&nbsp;&nbsp;Get the WROX book on ADO (or sit at Borders and drink a cup'o joe.)&nbsp;&nbsp;Check out the ADO Command Object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top