Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

I'm using an adodb.recordset to query and obtain the contents of an Excel
file in ASP with VBScript.
I'm having a problem when there are numeric entries mixed with alpha &
numeric entries within the same column.
The query I use seems to pick one of the two types and return NULL for any
of the other type.
Is there a way to specify that the columns will all be of a specific type?
I've tried to set the format in the Excel file to all General or all Text
but that doesn't seem to help. Any ideas would help, thanks.
Here's some code of what i'm doing basically:
....
Set XLconn = CreateObject("ADODB.Connection") 'Excel connection object
XLconn.ConnectionString = connectstr
XLconn.Open
Set XLrs = CreateObject("ADODB.Recordset") 'create the record set object
XLrs.cursortype = 3
XLrs.open "Select * From [sheet1$]", XLconn
....
Thanks,
Nate


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default adodb.recordset with excel

Nate

Here's everything you ever wanted to know about mixed data types

http://www.dicks-blog.com/excel/2004...al_data_m.html

Thanks to OneDayWhen for this awesome contribution.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"nate axtell" <naxtell at progeny dot net wrote in message
...
I'm using an adodb.recordset to query and obtain the contents of an Excel
file in ASP with VBScript.
I'm having a problem when there are numeric entries mixed with alpha &
numeric entries within the same column.
The query I use seems to pick one of the two types and return NULL for any
of the other type.
Is there a way to specify that the columns will all be of a specific type?
I've tried to set the format in the Excel file to all General or all Text
but that doesn't seem to help. Any ideas would help, thanks.
Here's some code of what i'm doing basically:
...
Set XLconn = CreateObject("ADODB.Connection") 'Excel connection object
XLconn.ConnectionString = connectstr
XLconn.Open
Set XLrs = CreateObject("ADODB.Recordset") 'create the record set object
XLrs.cursortype = 3
XLrs.open "Select * From [sheet1$]", XLconn
...
Thanks,
Nate




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

ok, I'm using a different driver:
connectstr = "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" &
FileName & ";"
But, from the link you gave talks about registry settings, which I can not
touch since this app will be used from client machines.



"Dick Kusleika" wrote in message
...
Nate

Here's everything you ever wanted to know about mixed data types

http://www.dicks-blog.com/excel/2004...al_data_m.html

Thanks to OneDayWhen for this awesome contribution.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default adodb.recordset with excel

Nate

ok, I'm using a different driver:
connectstr = "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ=" &
FileName & ";"


I think the theory is the same regardless of the driver. It would just be
in a different place in the registry. I'm just guessing though.

But, from the link you gave talks about registry settings, which I can not
touch since this app will be used from client machines.


That's going to make it tough, I think. The only other way that I can think
of is to open the source workbook and insert some rows with data of a
particular type. If you can open the workbook, though, you can just copy
the range over and not use ADO. Any chance you can just open the workbook?

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

No, a workbook is considered an unsafe activex control i thought, which we
have prompt the user everytime one is found (IE setting). So we wouldn't
want to go with that. I just posted a message before this about the
registry key already being what I want it to be.
Nate

"Dick Kusleika" wrote in message
...
Nate

ok, I'm using a different driver:
connectstr = "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;DBQ="

&
FileName & ";"


I think the theory is the same regardless of the driver. It would just be
in a different place in the registry. I'm just guessing though.

But, from the link you gave talks about registry settings, which I can

not
touch since this app will be used from client machines.


That's going to make it tough, I think. The only other way that I can

think
of is to open the source workbook and insert some rows with data of a
particular type. If you can open the workbook, though, you can just copy
the range over and not use ADO. Any chance you can just open the

workbook?

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

Thanks again for the link, Dick.
I was checking out the registry for ImortMixedTypes and I found mine set to
"Text".
The link you posted says "IMEX=0 and IMEX=2 result in ImportMixedTypes being
ignored and the default value of 'Majority Types' is used. IMEX=1 is the
only way to ensure ImportMixedTypes=Text is honored"...

Do you know if this means that the ImortMixedTypes key is supposed to be
"Majority Types" by default or that that is just a default that is used by
the driver? I am worried that ImportMixedTypes wont be "Text" for every
clients' installation by the wording of the qoute above. If it is always
Text then I should be fine.

Thanks, Nate



"Dick Kusleika" wrote in message
...
Nate

Here's everything you ever wanted to know about mixed data types

http://www.dicks-blog.com/excel/2004...al_data_m.html

Thanks to OneDayWhen for this awesome contribution.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"nate axtell" <naxtell at progeny dot net wrote in message
...
I'm using an adodb.recordset to query and obtain the contents of an

Excel
file in ASP with VBScript.
I'm having a problem when there are numeric entries mixed with alpha &
numeric entries within the same column.
The query I use seems to pick one of the two types and return NULL for

any
of the other type.
Is there a way to specify that the columns will all be of a specific

type?
I've tried to set the format in the Excel file to all General or all

Text
but that doesn't seem to help. Any ideas would help, thanks.
Here's some code of what i'm doing basically:
...
Set XLconn = CreateObject("ADODB.Connection") 'Excel connection object
XLconn.ConnectionString = connectstr
XLconn.Open
Set XLrs = CreateObject("ADODB.Recordset") 'create the record set object
XLrs.cursortype = 3
XLrs.open "Select * From [sheet1$]", XLconn
...
Thanks,
Nate






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

Another concern,
I have tried IMEX=1 with the Jet driver and I DO see the results I want,
Number fields and Text fields are being returned together.
but in the case where a number is quite long I see 9911220193 in the excel
file but when it gets read into the recordset and then passed over to SQL
server I see "9.91122E+009". This is quite strange. Any idea why this
scientific notation is showing up?
Thanks again,
Nate


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default adodb.recordset with excel

Nate

"nate axtell" <naxtell at progeny dot net wrote in message
...
Another concern,
I have tried IMEX=1 with the Jet driver and I DO see the results I want,
Number fields and Text fields are being returned together.
but in the case where a number is quite long I see 9911220193 in the excel
file but when it gets read into the recordset and then passed over to SQL
server I see "9.91122E+009". This is quite strange. Any idea why this
scientific notation is showing up?
Thanks again,
Nate


Pure guessing here. I don't know much about SQL server, but it almost looks
like it's converting the number to fits its own data type. Like if that
field was set for Integer and needed to be set for Long Integer.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default adodb.recordset with excel

I've done some testing and it happens before SQL Server gets its hands on
it.
It happens when the rows get put into the recordset. I can't see the
recordset changing it to scientific notation so I'm going to assume that
Excel is converting it over to Sci. Not. before it gets brought over as a
string.
Any ideas about how and why Excel would return the value in Sci. Not.?
thanks,
Nate


"Dick Kusleika" wrote in message
...
Nate

"nate axtell" <naxtell at progeny dot net wrote in message
...
Another concern,
I have tried IMEX=1 with the Jet driver and I DO see the results I want,
Number fields and Text fields are being returned together.
but in the case where a number is quite long I see 9911220193 in the

excel
file but when it gets read into the recordset and then passed over to

SQL
server I see "9.91122E+009". This is quite strange. Any idea why this
scientific notation is showing up?
Thanks again,
Nate


Pure guessing here. I don't know much about SQL server, but it almost

looks
like it's converting the number to fits its own data type. Like if that
field was set for Integer and needed to be set for Long Integer.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default adodb.recordset with excel


"nate axtell" <naxtell at progeny dot net wrote in message
...
Thanks again for the link, Dick.
I was checking out the registry for ImortMixedTypes and I found mine set

to
"Text".
The link you posted says "IMEX=0 and IMEX=2 result in ImportMixedTypes

being
ignored and the default value of 'Majority Types' is used. IMEX=1 is the
only way to ensure ImportMixedTypes=Text is honored"...

Do you know if this means that the ImortMixedTypes key is supposed to be
"Majority Types" by default or that that is just a default that is used by
the driver? I am worried that ImportMixedTypes wont be "Text" for every
clients' installation by the wording of the qoute above. If it is always
Text then I should be fine.


The way I understand it is that ImportMixedTypes is "Text" by default. But
IMEX is NOT 1 by default, so ImportMixedTypes is ignored - by default. It
would follow then that if you declare IMEX in your extended properties AND
the user has not changed their default, then it will work. I think that
"the default value of 'Majority Types' is used" means that IMEX < 1 by
default and Majority Types is the default for an IMEX < 1, not that
Majority Types is the default for that registry key.

Whether you want to rely on user's default not being changed is up to you.
On my Win98SE, it's "Text" and I know I've never changed it.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
access database (adodb)from excel vba AskExcel Excel Worksheet Functions 0 July 17th 06 02:01 AM
Virus - importing excel via adodb connection Jim M[_4_] Excel Programming 1 May 15th 04 08:09 AM
Retreiving data from Excel spreadsheet through ADODB Roel Excel Programming 2 March 3rd 04 05:01 PM
Export from Excel to Access ADODB javydreamercsw Excel Programming 2 February 19th 04 09:49 PM
ADODB Recordset Seth[_3_] Excel Programming 0 August 5th 03 02:15 PM


All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"