borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (databound combobox)Next Topic (INSERT - Dynamic values) New Topic New Poll Post Reply
AndreaVB Forum : Database : Passing Parameters to Stored MSAccess Queries thru ADO Data-Envmnt
Poster Message
perplexd
Level: Guest


icon Passing Parameters to Stored MSAccess Queries thru ADO Data-Envmnt  Archived to Disk

I'm trying to pass parameters to an Query within an Access database. It must be done this way as the database will eventually be on a server, and I want the server to do the work.

I've tried doing these sort of things...but they don't work:

dataEnv.qry!parameter = txtParam.Text
dataEnv.qry.parameter = txtParam.Text
dataEnv.qry parameter = txtParam.Text
dataEnv.qry (parameter = txtParam.Text)
dataEnv.qry ([parameter] = txtParam.Text)
dataEnv.qry [parameter] = txtParam.Text

(The qry is listed as a stored-proceedure within a connection object)

Help much appreciated.

29-05-2002 at 02:28 PM
| Quote Reply
w32crazydev
Level: Guest

icon Re: Passing Parameters to Stored MSAccess Queries thru ADO Data-Envmnt  Archived to Disk

hello i think i can help you..

the following command creates an input parameter on the conne object

conne.Parameters.Append conne.CreateParameter("myfield_id",_
adInteger, adParamInput)

in order to understand a full code see this

Dim toconne As Connection
Dim mycmd As Command
Dim myrs As Recordset

'Create the dynamic pointer
Set toconne=New Connection
Set mycmd=New Command

'open the db using the jet provider
toconne.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=filename.mdb"
toconne.Open

mycmd.CommandType=adCmdUnknown
mycmd.CommandText="[the description]"

'create your parameter like this
mycmd.Parameters.Append _
mycmd.CreateParameter("a_date",adDate, _
adParamInput)

mycmd.Parameters.Append _
mycmd.CreateParameter("b_date",adDate, adParamInput)

'Set your values like this

mycmd.Parameters("a_date").Value= "8/2/1983" 'do the same for b_date

'Make your command associate with an active connection

mycmd.ActiveConnection=toconne

'get your records

Set myrs=mycmd.Execute     

Alexander Lykourgos, www16.brinkster.com/w32crazydev

22-07-2002 at 06:48 PM
| Quote Reply
AndreaVB Forum : Database : Passing Parameters to Stored MSAccess Queries thru ADO Data-Envmnt
Previous Topic (databound combobox)Next Topic (INSERT - Dynamic values) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder