i have strange problem. use mysql connector.net mysqlreader.read()
returns true , false. mysqlreader.hasrows
true both cases , in visualstudio can see reader object hold values.
why happen?
here code:
mysqlcommand sqlcommand = new mysqlcommand(sqlcode, this._conn); mysqldatareader rdr = sqlcommand.executereader(); populatemessage("--> " + servername + ": " + dbname); int fields = rdr.visiblefieldcount; //make headers int[] fmaxl = new int[fields]; string[] headers = new string[fields]; list<string[]> vals = new list<string[]>(); if (rdr.hasrows) { (int hi = 0; hi < fields; hi++) { string val = rdr.getname(hi); headers[hi] += val; fmaxl[hi] = val.length; } while (rdr.hasrows && rdr.read()) // <-- here read() method returns // false or true // while hasrows true { ...
eidt: rdr
holds example 99 rows values (checked in vs) , @ first call read()
method returns false. joachim making me put useful notice.
this hasrows property isn't in versions of .net. why not recast code this?
boolean firstrow = true; while (rdr.read()) { if (firstrow) { // column names, once firstrow = false; (int hi = 0; hi < fields; hi++) { string val = rdr.getname(hi); headers[hi] += val; fmaxl[hi] = val.length; } } ... //process each row. }
having done tonnage of kind of stuff, know works pretty well.
Comments
Post a Comment