
Executing Parameter Query with 2 parameters
Quote:
>-----Original Message-----
>Good morning:
>Would someone please show me how to execute a parameter
query in Access
>2000, passing 2 values and returning the results to an
ado recordset. Thank
Quote:
This example is using SQL Server 7, but if you substitute
the MS Jet Engine for the connection it should work.
Dim cmd As ADODB.Command
Dim rst AS ADODB.Recordset
cmd.ActiveConnection = _
"provider=SQLOLEDB.1;password=nemisis;persist security
info=true;user id=sheldon," & _
"initial catalog=EAC;data source=desktop"
cmd.commandType = adCmdText
cmd.CommandText = "Select * from passwd where name=? and
passwd=?"
Set rst = cmd.Execute(Parameters:Array(username, password))
username and password are the parameters to be passed in
the SQL Query.
Hope this helps.