asp.net - Specified cast is not valid when reading a Float column -
well stuck... again. sailing smooth until now. reading data db (something usual) giving me specified cast not valid error. not first time i've dealt error; earlier on had date column. anyway, have table need read. data type float. code using:
dim rdr = sqlcmd.executereader while rdr.read theresults.add(new userdata { .balavailable = rdr.getfloat(0), .branch = rdr.getint32(1) }) end while
this running under function; class...
class userdata dim theresults = new list(of userdata) property branch integer property balavailable single end class
and input part...
dim clientno integer = 0 dim myresults = getdata(clientno) if integer.tryparse(txtinput.text, clientno) if myresults.count = 1 txtbalavail.text = cint(myresults(0).balavail) else
everytime input value gives me specified cast not valid error.
system.data.sqlclient.sqlbuffer.get_int32() +5270501 system.data.sqlclient.sqldatareader.getint32(int32 i) +62
i believe related statements use?
imports system.data imports system.data.sqlclient imports system.configuration
i stuck. tried changing rdr.getfloat double, , in integer.tryparse double.tryparse. stuck!
the strongly-typed get...
methods (getfloat
, getint32
, etc.) work if data-type of field exact match.
use getfieldtype
method examine real data-type of field, , either use appropriate strongly-typed get...
method, or untyped getvalue
method.
Comments
Post a Comment