Re: Problems with IDataRecord.IsDBNull
- From: "Chukkalove" <someone@xxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 11:35:55 +0100
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
.
- Follow-Ups:
- Re: Problems with IDataRecord.IsDBNull
- From: Marina Levit [MVP]
- Re: Problems with IDataRecord.IsDBNull
- References:
- Problems with IDataRecord.IsDBNull
- From: Chukkalove
- Re: Problems with IDataRecord.IsDBNull
- From: Frans Bouma [C# MVP]
- Problems with IDataRecord.IsDBNull
- Prev by Date: Re: Multiple oracle homes - need to choose
- Next by Date: Re: Typed DataTable - NewRow() - Identity Field
- Previous by thread: Re: Problems with IDataRecord.IsDBNull
- Next by thread: Re: Problems with IDataRecord.IsDBNull
- Index(es):
Relevant Pages
|
|