[Mono-bugs] [Bug 77535][Nor] New - Sqlite DataReader's GetString crashes on null value in DB

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Feb 12 08:40:05 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by nazgul at omega.pl.

http://bugzilla.ximian.com/show_bug.cgi?id=77535

--- shadow/77535	2006-02-12 08:40:05.000000000 -0500
+++ shadow/77535.tmp.10349	2006-02-12 08:40:05.000000000 -0500
@@ -0,0 +1,74 @@
+Bug#: 77535
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: tsenganal at novell.com                            
+ReportedBy: nazgul at omega.pl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Sqlite DataReader's GetString crashes on null value in DB
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+GetString does not handle null value in DB 
+
+Steps to reproduce the problem:
+1. Compile and run following program (mcs -r:Mono.Data.SqliteClient.dll t.cs):
+
+ using System;
+ using System.Data;
+ using Mono.Data.SqliteClient;
+ 
+ public class Test 
+ {
+    public static void Main(string[] args)
+    {
+       string connectionString = "URI=file://SqliteTest.db, Version=3";
+
+       SqliteConnection dbcon = new SqliteConnection(connectionString);
+       dbcon.Open();
+
+       SqliteCommand dbcmd = (SqliteCommand)dbcon.CreateCommand();
+       dbcmd.CommandText = "CREATE TABLE user (name VARCHAR(10)); INSERT
+INTO user VALUES (null);";
+       dbcmd.ExecuteNonQuery();
+       dbcmd.Dispose();
+
+       dbcmd = dbcon.CreateCommand();
+       dbcmd.CommandText = "SELECT name FROM user";
+      
+       IDataReader reader = dbcmd.ExecuteReader();
+       while(reader.Read()) {
+            string name = reader.GetString (0);
+            Console.WriteLine("Name: " + name);
+       }
+       // clean up
+       reader.Close();
+       dbcmd.Dispose();
+       dbcon.Close();
+    }
+ }  
+
+Actual Results:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object.
+   at Mono.Data.SqliteClient.SqliteDataReader.GetString(Int32 i)
+   at Test.Main(String[] args)
+
+Expected Results:
+Name:
+
+How often does this happen? 
+Always
+
+Additional Information:
+It worked fine some time ago


More information about the mono-bugs mailing list