Type mismatch transferrring recordset to array? 
Author Message
 Type mismatch transferrring recordset to array?

    sSQL = "SELECT * FROM " & stblCategories
    Set ADODBRecordset = CreateObject("ADODB.Recordset")
    ADODBRecordset.Open sSQL, ADODBConnection, adOpenStatic
    intRecordCount = ADODBRecordset.RecordCount
    Dim arrCategories '<== simple variant to hold returned array...
    ADODBRecordset.MoveFirst
    arrCategories = ADODBRecordset.GetRows

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I am trying to transfer an ADO recordset to an array. The recordset is
> pulled from a SQL database and has two columns, both text, no nulls in
> either. Everything works fine until I actually try the transfer when I get a
> message indicating there is a 'type mismatch'.

>     sSQL = "SELECT * FROM " & stblCategories
>     Set ADODBRecordset = CreateObject("ADODB.Recordset")
>     ADODBRecordset.Open sSQL, ADODBConnection, adOpenStatic
>     intRecordCount = ADODBRecordset.RecordCount
>     ReDim arrCategories(intRecordCount - 1, 1)
>     ADODBRecordset.MoveFirst
>     arrCategories = ADODBRecordset.GetRows <<<====== fails with a type
> mismatch error.

> Anyone got any ideas?

> __________________________________________
> Al Blake,  Information Technology Manager
> Secretariat of the Pacific Community.
> BPD5 98848 Noumea Cedex.
> New Caledonia.
> Tel +687 26.01.44 Fax +687 26.38.18




Fri, 11 Apr 2003 03:00:00 GMT  
 Type mismatch transferrring recordset to array?

I am trying to transfer an ADO recordset to an array. The recordset is
pulled from a SQL database and has two columns, both text, no nulls in
either. Everything works fine until I actually try the transfer when I get a
message indicating there is a 'type mismatch'.

    sSQL = "SELECT * FROM " & stblCategories
    Set ADODBRecordset = CreateObject("ADODB.Recordset")
    ADODBRecordset.Open sSQL, ADODBConnection, adOpenStatic
    intRecordCount = ADODBRecordset.RecordCount
    ReDim arrCategories(intRecordCount - 1, 1)
    ADODBRecordset.MoveFirst
    arrCategories = ADODBRecordset.GetRows <<<====== fails with a type
mismatch error.

Anyone got any ideas?

__________________________________________
Al Blake,  Information Technology Manager
Secretariat of the Pacific Community.
BPD5 98848 Noumea Cedex.
New Caledonia.
Tel +687 26.01.44 Fax +687 26.38.18



Sat, 12 Apr 2003 07:11:13 GMT  
 Type mismatch transferrring recordset to array?
Quote:

> ReDim arrCategories(intRecordCount - 1, 1)
>     ADODBRecordset.MoveFirst
>     arrCategories = ADODBRecordset.GetRows <<<====== fails with a type
> mismatch error.

> Anyone got any ideas?

I think the problem is the default type for Array elements in VBScript
is Variant, and the default type for recordset is string.  Try setting a
recordset field to a variable, to force a conversion, and then stuff
that variable into the array element.

 Hollis D. Paul [MVP - Outlook]


 Using Virtual Access 4.52 build 277 (32-bit), Windows 2000 build 2195

 Mukilteo, WA  USA



Sat, 12 Apr 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Type mismatch transferrring recordset to array?

2. Type Mismatch error sending array or recordset variables to MTS from ASP

3. Type Mismatch - Array of Type Long

4. VB5 NT4 ADO recordset WSH type mismatch - a note

5. VB5 NT4 ADO recordset WSH type mismatch - a note

6. Type mismatch on array

7. type mismatch when modifying an array

8. Type Mismatch for Array

9. Type mismatch in a private array defined in a class

10. Type Mismatch on my array elements.

11. Arrays dim'd at class scope get type mismatch

12. Type Mismatch returning variant array from COM object

 

 
Powered by phpBB® Forum Software