Excel and Typcasted Columns

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

Grettings all,

I'm having a problem with accessing data in a column of an Excel
spreadsheet.

It seems that when I access the spreadsheet using Oledb Connection
method, a column get's typecasted according to the type of that column
that occupies 51% of that data.

So, when I'm trying to retrieve all the data in that column, if 51% of
the column is integer, it nulls out the non-integer values!?

Here's example of the connection string

Dim DBCon As System.Data.OleDb.OleDbConnection

DBCon = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data
source=C:\Publisher.XLS;Extended
Properties=Excel 8.0;")

DBCommand = New System.Data.OleDb.OleDbDataAdapter("select * from
[Inventory$]", DBCon)

Thanks in advance for the help,

jT
 
Assuming all of the data will conform the type
cast...remember you own the data once you get it. Lot's
of way's to handle it. Convert/Cast it in the SQL
Statement (but if everything isn't correct, this will
cause an exception). But if you KNOW that the data
is 'safe', set it locally with a datacolumn. Too many
ways to get around this to post the code, but you can
iterate through it and ensure everything is cool or set a
bool and use exceptions, if clean, create new column...
fill it and kill the old one..

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfSystemDataDataColumnClassDataTypeTopic.
asp

Good Luck

Bill
 
Back
Top