c# - OledbDataReader is not retriving all the colums -


hey guys i'm have little problem in retrieving data table here's code: if column in db table empty exception thrown...

                  string cmdtext = "select member_id,disp_id,mobile_no,tm,pm,lm,due_date recharge";                 string updatestatus = "",hepupdatestatus="";                 oledbcommand cmdfinalupdate = new oledbcommand(cmdtext, conn);                 oledbdatareader updatereader = cmdfinalupdate.executereader();                 if (!updatereader.hasrows) // condition creating problem                     messagebox.show("no data pending updation");                 else                 {                     try                     {                         while (updatereader.read())                         {                             program.memberid = convert.toint64(updatereader.getint32(0));                             program.dispid = updatereader.getstring(1);                             program.mobile = updatereader.getstring(2);                             program.tm = updatereader.getstring(3);                             program.pm = updatereader.getstring(4);                             program.remarks = updatereader.getstring(5);                             program.duedate = updatereader.getstring(6);                        }                     }                     catch (exception) { }                                         {                         updatereader.close();                     }                    }  

the problem is, giving error on forth column i.e program.pm = updatereader.getstring(4); error specified cast not valid (actually after 3rd column giving exception) im pretty sure casting not issue, coz when remove if condtion @ top i.e if (!updatereader.hasrows) code works fine, wanna know problem reader if m checkin' reader has rows or not ?

from the getstring() documentation:

no conversions performed; therefore data retrieved must string.

looks recharge.pm not string or contains null value.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -