Empty table (ADO) 
Author Message
 Empty table (ADO)

In my VB 6.0 program I have the following statements:
   Dim rs As ADODB.Recordset
   rs.Open "SELECT * FROM myTable;", cnn, adOpenStatic, adLockOptimistic
   If rs.RecordCount > 0 Then ...
cnn is declared earlier and is open. myTable is empty.
I receive the error 91: "Object variable or With block variable not set" on
my open statement.

Am I misunderstanding anything here or is my brain just stopped...? This
should be "a piece of cace"?

Kjell Weding



Mon, 02 May 2005 20:17:37 GMT  
 Empty table (ADO)
After this line:
Dim rs As ADODB.Recordset

Add this
Set rs = New ADODB.Recordset

You have cleared a place in memory for the recordset object with the DIM
statement, but had not instantiated the recrodset object with a SET
statement.

--
Veign
www.veign.com
<<NEW Link200 v2.0.2 Released>> - Bigger, Better, Cleaner!
www.veign.com/download_application.html#Link200
Code Samples & Sample Projects
http://www.veign.com/information/application/info_app.html
Submit Your Best Code (you keep the rights)
http://www.veign.com/information/application/code_submit.html
---------

Quote:
> In my VB 6.0 program I have the following statements:
>    Dim rs As ADODB.Recordset
>    rs.Open "SELECT * FROM myTable;", cnn, adOpenStatic, adLockOptimistic
>    If rs.RecordCount > 0 Then ...
> cnn is declared earlier and is open. myTable is empty.
> I receive the error 91: "Object variable or With block variable not set"
on
> my open statement.

> Am I misunderstanding anything here or is my brain just stopped...? This
> should be "a piece of cace"?

> Kjell Weding




Mon, 02 May 2005 22:32:26 GMT  
 Empty table (ADO)

In my VB 6.0 program I have the following statements:
   Dim rs As ADODB.Recordset
   rs.Open "SELECT * FROM myTable;", cnn, adOpenStatic, adLockOptimistic
   If rs.RecordCount > 0 Then ...
cnn is declared earlier and is open. myTable is empty.
I receive the error 91: "Object variable or With block variable not set" on
my open statement.

Am I misunderstanding anything here or is my brain just stopped...? This
should be "a piece of cace"?

You need to create an instance of the Recordset object before you access it:

     Set rs = New ADODB.Recordset


Microsoft MVP (Visual Basic)



Mon, 02 May 2005 23:20:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. to DELETE an empty table gives me a error..(Ado and AS400)

2. Empty resultset when adding to empty table : error

3. Empty tables in a multi-tables query

4. Empty tables in a multi-tables query

5. linked table empty

6. filling in empty table

7. Problem with Empty or Null fields in a Table on a Report

8. Append Query on empty table

9. Empty Tables and Errors

10. create empty table from query

11. Checking for empty table

12. Updating empty strings in a table

 

 
Powered by phpBB® Forum Software