excel adodb query datatype issues

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
I have a query that's been working great, until we challenged it, by providing different value types in one column.

lets say I have 5 rows of data in column A (each cell value contains: 22005) that I want to capture to recordset.
Query: SELECT F1 AS [instructions] FROM [Worksheet$]
The above query works returning 5 rows of 22005.

Now, if I have 5 rows of data, and the first row is equal to 22005 and the second row equal to apple and the rows afterwards, are 22005, the recordset will return all values except for the apple; apple will come back NULL.
If I put apple in the first row, same thing; will happen; Null is returned, but the other rows with 22005 are returned.
I'm not sure what the problem is, since I have other columns with apple, that all come back apple.
Any idea's why I'm getting some data back as NULL?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
ADO doesn't really like mixed data types (databases don't generally allow it). You can try and work round it by adding IMEX=1 to your connection string, but it's not foolproof by any means.
 
Upvote 0
Solution
ADO doesn't really like mixed data types (databases don't generally allow it). You can try and work round it by adding IMEX=1 to your connection string, but it's not foolproof by any means.
your right; seeing some other posts now, saying similarly. It's too bad you cant use cast in the select statement, to determine the column data type; in my case, I just want it return all as varchar
 
Upvote 0
It doesn't always work if the first instance of your mixed data type is not near the top of the data set.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top