unwanted Type of System.DBNull

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();
 
W

William Ryan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top