Re: Problems with IDataRecord.IsDBNull



Thanks for your reply Frans

The database is MySQL, using their dot net connector libraries for ADO. Is
this a problem with the provider or dotnet?
I tried using your suggestion
if (reader.GetValue(nCount) == System.DBNull.Value) foo();
And received the same exception where the value in the column was out of
bounds ie the field was not null but holds a value which is out of range for
DateTime "0000-00-00 00:00:00"

My hack for this is as follows, but it's horrible!
public void ReadFromReader(IDataReader reader)
{
string fnName = "ReadFromReader";

try
{
// check each column for null values
for (int nCount = 0; nCount < reader.FieldCount; nCount++)
{
try
{
if (reader.GetValue(nCount) == System.DBNull.Value) continue;
}
catch
{
continue;
}

string column = reader.GetName(nCount);
ReadFields(reader, column);

}//for

}
catch(Exception e)
{
LogException(fnName, e);
throw e;
}// catch
}// function


.



Relevant Pages

  • Re: Why not use DAO?
    ... You have been refering to DAO vs. ADO when these two things (in the context ... you must have ALREADY used a provider to get to. ... interface for working with JET databases. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Why not use DAO?
    ... All reall life programmers i know of use the jet oledb 3.5 or 4.0 provider ... ADO for ACCESS ... The TS asked "Why not used DAO ?" ... interface for working with JET databases. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Regarding fastest database interaction with Oracle in VC++
    ... If you are using ADO, then you will have a Connection object. ... is a lightweight COM API that sits on top of OLEDB. ... If you install MDAC 2.8, it will install some providers for you. ... It will install the MS Oracle provider. ...
    (microsoft.public.vc.database)
  • Re: Using crystal reports with MySQL ADO connector
    ... to use ADO components with our application. ... The database we're developing with is MySQL. ... Connector/NET components which are ADO compliant. ... The example in the above link uses a wizard to link to OLE DB provider ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Mysterious OLE DB DBID propids
    ... strange properties, interfaces, etc. ... ADO that causes ADO to ask for the DBIDs? ... provider is related to it. ... msdshape.h file and adc.h file (for the client ...
    (microsoft.public.data.oledb)