asp.net - Read text from .xls in C# -
i try read .xls flies in c#. if first data column text says dbnull.value =true. if number ok. how read text?
this code:
oledbcommand command = new oledbcommand("select [id], [name], [email] [sheet$]", connection); oledbdataadapter objadapter = new oledbdataadapter(); objadapter .selectcommand = command; dataset objdataset = new dataset(); objadapter .fill(objdataset1); dataview dv = objdataset .tables[0].defaultview; (int = 0; < dv.count; i++) { if (dv[i][0] != dbnull.value ) // problem here.... if first column text true. want tead text well. { } }
try:
string dval = dv[i][0] string; if(dval != null) { //use string to use string, have call tostring() method. i.e.:
dv[i][0].tostring()
Comments
Post a Comment