sql - Provider type could not be represented as a .NET type OracleTypeException -
so have application writing oracle database, reading data same database.
when line dim msgtime timespan = reader.gettimespan(2)
, exception (see below).
the oracle documentation says interval day second
(which how i'm storing data in db) can converted timespan (see here)
does know causes exception, , how avoid it?
thanks.
exception:
oracle.dataaccess.types.oracletypeexception provider type not represented .net type @ oracle.dataaccess.types.timespanconv.gettimespan(opoitlvalctx* pvalctx, oracledbtype oratype) @ oracle.dataaccess.client.oracledatareader.gettimespan(int32 i) @ myprogram.polldatabase(object sender, doworkeventargs e)
write db code:
dim ocommand new oraclecommand("insert logtable(pk, mid,mdate,mtime,status,severity,origq,message) values (:pk, :msgid, :msgdate, :msgtime, :status, :severity, :message)") ocommand.parameters.add("pk", oracledbtype.varchar2, guid.newguid().tostring().substring(0, 12), parameterdirection.input) ocommand.parameters.add("msgid", oracledbtype.varchar2, message.messageid, parameterdirection.input) ocommand.parameters.add("msgdate", oracledbtype.date, putdatesql, parameterdirection.input) ocommand.parameters.add("msgtime", oracledbtype.intervalds, puttimesql, parameterdirection.input) ocommand.parameters.add("status", oracledbtype.varchar2, "new", parameterdirection.input) ocommand.parameters.add("severity", oracledbtype.varchar2, messageseverity, parameterdirection.input) ocommand.parameters.add("message", oracledbtype.clob, clob, parameterdirection.input)
read db code:
dim conn oracleconnection = new oracleconnection(oradb) dim ocommand new oraclecommand("select mid,mdate,mtime,status,severity, origq, message logtable") ocommand.commandtype = commandtype.text ocommand.connection = conn ocommand.connection.open() dim reader oracle.dataaccess.client.oracledatareader = ocommand.executereader() if reader.hasrows while reader.read() try dim messageid string = reader.getstring(0) dim msgdate date = reader.getdatetime(1) if not reader.isdbnull(2) dim msgtime timespan = reader.gettimespan(2) end if dim msgstatus string = reader.getstring(3) dim msgseverity string = reader.getstring(4) dim msgorigin string = reader.getstring(5) dim msgcontent string = reader.getstring(6) catch ex exception console.out.writelineasync(ex.message) end try end while end if
i needed use dim msgtimeinterval oracle.dataaccess.types.oracleintervalds = reader.getoracleintervalds(2)
instead of dim msgtime timespan = reader.gettimespan(2)
Comments
Post a Comment