I am converting a program to ADO, and have worked out most of the bugs, except the sql query I was using to get a listview is not working now. I was using this code to open a recordset:




Set rsListData = dbPrimary.OpenRecordset( _
"SELECT * FROM qryListCustomers WHERE LastName LIKE '" & txtFind.Text & "*" & "'", _
dbOpenDynaset)





And getting:





Run-time error '3001':

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.





Since this is ADODB I changed the code to:



Set cmdCustomers = New ADODB.Command
cmdCustomers.CommandText = "SELECT * FROM qryListCustomers WHERE LastName LIKE '" & txtFind.Text & "*" & "'"
cmdCustomers.CommandType = adCmdText

Set paramCustomerID = _
cmdCustomers.CreateParameter("paramCustomerID")
paramCustomerID.Type = adInteger
paramCustomerID.Direction = adParamInput
paramCustomerID.Value = 10
cmdCustomers.Parameters.Append paramCustomerID

Set rsListData = New ADODB.Recordset
rsListData.Open cmdCustomers



But now I am getting:



Run-time error '3079':

Operation is not allowed on an object referencing a closed or invalid connection.



The error is occurring at rsListData.Open cmdCustomers
I believe my connection is open. The code I am using for it is:



dbCust.CursorLocation = adUseClient
dbCust.Open "Provider=Microsoft.Jet.OLEDB.3.51;" _
& "Data Source=C:\My Documents\VBasic\IllustrationADO\Customers\Customers2000.mdb;"




Which is the database holding the tables and query. Any ideas?