[Mono-dev] NullReference Exception for IDataReader.Get
~ * ~ Srijith Unni ~ * ~
srijith.unni at gmail.com
Thu Jul 19 05:38:45 EDT 2007
Hi All,
I am using Mono to read from a sqlite database, using IDataReader
I am getting a NullReference Exception when I have read a
particular row and when i call reader.GetString method to retrieve a field.
This happens only when the specific field in the row is empty. I was under
the impression that if the field is empty , the method should return either
null or an empty string. Don`t know why it is raising an Exception.
My code is like this,
IDbCommand cmd = Connection.CreateCommand ();
cmd.CommandText = query;
try {
IDataReader reader = cmd.ExecuteReader ();
while (reader.Read ()) {
key = reader.GetString(offset + 1);
...
}
The stack trace seen is ,
Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
at Mono.Data.SqliteClient.SqliteDataReader.GetString (Int32 i)
[0x00000]
Am I doing something wrong or has this been rectified in a later version.
I am using Mono 1.2.2 ( posting to this list, because it feels like a bug! )
Any help or comments, would be greatly appreciated.
--
Thanks & Regards,
--
A.Srijith.K.Unni
Mail ID : srijith.unni at gmail.com <//srijith%2Eunni at gmail.com/>
Home Page : http://srijith.unni.googlepages.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070719/9ee6df97/attachment.html
More information about the Mono-devel-list
mailing list