PDA

Click to See Complete Forum and Search --> : Problems executing an Access query with parameters


Pati Solis
Jul 12th, 2000, 07:41 PM
Hello! I have a problem running an Access query. The fist time I execute it works fine, but when I execute it the second time it keeps sending me the same records of the first time.

The query is made with Access 2000.
I´m working with VB 6.0 SP3

Here is an example of the code I´m using:


Dim BuscaCuenta As ADODB.Command
Dim BCParam1 As ADODB.Parameter
Dim BCParam2 As ADODB.Parameter
Dim TablaCta As ADODB.Recordset


Private Sub Command1_Click()

Set BCParam1 = New ADODB.Parameter
Set BCParam2 = New ADODB.Parameter
Set BuscaCuenta = New ADODB.Command
Set TablaCta = New ADODB.Recordset



BCParam1.Name = "EmpresaID"
BCParam1.Type = adChar
BCParam1.Size = 6
BCParam1.Direction = adParamInput

BCParam2.Name = "CuentaID"
BCParam2.Type = adChar
BCParam2.Size = 23
BCParam2.Direction = adParamInput


With BuscaCuenta
Set .ActiveConnection = GConeccion
.CommandText = "ConsCuenta"
.CommandType = adCmdStoredProc
.Parameters.Append BCParam1
.Parameters.Append BCParam2
End With


BuscaCuenta.Parameters("EmpresaID").Value = "000009"
BuscaCuenta.Parameters("CuentaID").Value = "1120.1.1.1"

Set TablaCta = BuscaCuenta.Execute()
TablaCta.Close

BuscaCuenta.Parameters("EmpresaID").Value = "000006"
BuscaCuenta.Parameters("CuentaID").Value = "1120.1.1.6"

Set TablaCta = BuscaCuenta.Execute()

' when I use the debug here to see what are the results of
' TablaCta.Fields I see the same data of the
' first execute

TablaCta.Close

End Sub

What am I missing? or what am I doing wrong?

Thank you!