BrianVSoft
asked on
Importing Excel with mixed format in the one column - gives NULL values (VB6 - ADODB)
I'm using VB8, ADODB to import Excel data..
One Column has a mixture of cell formats.. (Numeric and Text)
Eg. Col A1
10012 (Numeric)
10024A (Text)
The ADODB will only report values from only ONE of these types.. Ie. In one run, it will treat all the numerics as NULL.. In another run, all the Text will be NULL.
From my understanding of database, a fields can't behave like a Variant..
So, is there a solution other than pre-checking the excel files and forcing Text format on these columns? Most of my clients using this code don't have excel and so can't fix the worksheets.
In case its relevant, my connection style is as follows..
Dim XLcn As ADODB.Connection
Dim rsX As ADODB.Recordset
XLcn = "Provider=MSDASQL.1; Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;MaxBufferSize =2048; PageTimeout=5;"
rsX.Open "Select * From [Sheet1$]", XLcn
rsX.MoveFirst
rsX.Fields(0).Value '<- This value extracts as NULL when the data is numeric 10023
One Column has a mixture of cell formats.. (Numeric and Text)
Eg. Col A1
10012 (Numeric)
10024A (Text)
The ADODB will only report values from only ONE of these types.. Ie. In one run, it will treat all the numerics as NULL.. In another run, all the Text will be NULL.
From my understanding of database, a fields can't behave like a Variant..
So, is there a solution other than pre-checking the excel files and forcing Text format on these columns? Most of my clients using this code don't have excel and so can't fix the worksheets.
In case its relevant, my connection style is as follows..
Dim XLcn As ADODB.Connection
Dim rsX As ADODB.Recordset
XLcn = "Provider=MSDASQL.1; Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;MaxBufferSize
rsX.Open "Select * From [Sheet1$]", XLcn
rsX.MoveFirst
rsX.Fields(0).Value '<- This value extracts as NULL when the data is numeric 10023
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.