ADODB Recordset not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Why isn't this code working:

Dim con_ls As Object
Dim rs_ls As Object


Set con_ls = Application.CurrentProject.Connection
Set rs_ls = CreateObject("ADODB.Recordset")

rs_ls.Open "Select firmen_name from t_firmen where " & _
" firmen_grenze_unten < = " & ls_nummer & " and " & _
" firmen_grenze_oben > = " & ls_nummer & " )"

Always get an error message:
"This coonnection can not be used. The connection is closed or not valid"
That is a somehow rough translation from german.

jokobe
 
jokobe wrote in message
Why isn't this code working:

Dim con_ls As Object
Dim rs_ls As Object


Set con_ls = Application.CurrentProject.Connection
Set rs_ls = CreateObject("ADODB.Recordset")

rs_ls.Open "Select firmen_name from t_firmen where " & _
" firmen_grenze_unten < = " & ls_nummer & " and " & _
" firmen_grenze_oben > = " & ls_nummer & " )"

Always get an error message:
"This coonnection can not be used. The connection is closed or not valid"
That is a somehow rough translation from german.

jokobe

I can't find the starting parenthesis of your sql, but if you check the
help files on ADO recordsets, you'll need to pass the connection as
the second arguement

rs_ls.Open <sqlstring>, con_ls

then perhaps also add lock/cursortype, if needed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top