unwanted Type of System.DBNull

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I'm trying to get data out of an excel file, but for
first column below the Type is System.DBNull. The other
2 columns the Type is System.String. But then after a
few more rows, a second column's type becomes
System.DBNull so whenever the type is System.DBNull, I
can't get the cell value as a string.
What causes a cells Type to be System.DBNull?

tia
Randy


mytype = ds_sma.Tables["ExcelSheet"].Rows[intRow]
[194].GetType();
mytype = ds_sma.Tables["ExcelSheet"].Rows[intRow]
[195].GetType();
mytype = ds_sma.Tables["ExcelSheet"].Rows[intRow]
[193].GetType();
 
Randy:

The column value, I'm pretty sure isn't what's changing,
it's the cell value that's changing. You can get around
this by specifiying a default value, ie IIF(Not ISDBNull
(given cell reference), (given cell reference), "" )

That will give you an blank reference instead of a null.
If I understood your problem correctly, this should do it
for you. Let me know if this isn't what the problem is.

Good Luck,

Bill

W.G. Ryan
(e-mail address removed)
www.knowdotnet.com
 
Back
Top