[Mono-list] Exception thrown by IDataReader.Get

~ * ~ Srijith Unni ~ * ~ srijith.unni at gmail.com
Thu Jul 19 01:36:38 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

  Any help or comments, would be greatly appreciated.

-- 
Thanks & Regards,
--
A.Srijith.K.Unni

Mail ID : srijith.unni at gmail.com
Home Page : http://srijith.unni.googlepages.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070719/fb7a8bd0/attachment-0001.html 


More information about the Mono-list mailing list