[Mono-bugs] [Bug 76413][Nor] New - SqliteClient requires that parameter name passed to Parameters.Add is prefixed with :

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Oct 11 16:13:26 EDT 2005


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=76413

--- shadow/76413	2005-10-11 16:13:26.000000000 -0400
+++ shadow/76413.tmp.29390	2005-10-11 16:13:26.000000000 -0400
@@ -0,0 +1,128 @@
+Bug#: 76413
+Product: Mono: Class Libraries
+Version: 1.0
+OS: 
+OS Details: mono 1.1.9
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data.SqlClient
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: nazgul at omega.pl               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: SqliteClient requires that parameter name passed to Parameters.Add is prefixed with :
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+In all standard DB client providers (Npgsql, SqlClient) the following
+pattern works fine
+
+string sql = "SELECT * FROM x WHERE id = $name";
+dbcmd = new SqliteCommand(sql, dbcon);
+dbcmd.Parameters.Add ("name", DbType.String).Value = "Kamil";      
+
+(for $ changed into specific provider's parameter prefix)
+
+while SqliteClient expects the prefix to be specified both in SQL code and
+parameter name.
+
+
+Steps to reproduce the problem:
+1. Compile and run following code to initialize database
+
+ 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;
+       dbcon = new SqliteConnection(connectionString);
+       dbcon.Open();
+
+       SqliteCommand dbcmd = new SqliteCommand("CREATE TABLE employee
+(firstname varchar(10), lastname varchar (10))", dbcon);
+       dbcmd.ExecuteNonQuery();
+
+       dbcmd.Dispose();
+       dbcmd = null;
+       dbcon.Close();
+       dbcon = null;
+    }
+ }
+
+2. Compile and run testcase
+
+
+ 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;
+       dbcon = new SqliteConnection(connectionString);
+       dbcon.Open();
+
+       SqliteCommand dbcmd;
+
+       string sql = "SELECT firstname, lastname FROM employee WHERE
+firstname = :parm";
+      
+       dbcmd = new SqliteCommand(sql, dbcon);
+ 
+       // this should work
+       dbcmd.Parameters.Add ("parm", DbType.String).Value = "Kamil";      
+       // this works
+       //dbcmd.Parameters.Add (":parm", DbType.String).Value = "Kamil";      
+
+       IDataReader reader = dbcmd.ExecuteReader();
+       while(reader.Read()) {
+            string FirstName = (string) reader[0];
+            string LastName = (string) reader[1];
+            Console.WriteLine("Name: " + 
+                FirstName + " " + LastName);
+       }
+       // clean up
+       reader.Close();
+       reader = null;
+       dbcmd.Dispose();
+       dbcmd = null;
+       dbcon.Close();
+       dbcon = null;
+    }
+ }       
+
+
+Actual Results:
+Unhandled Exception: System.IndexOutOfRangeException: The specified name
+does not exist: :parm
+in <0x000c0> Mono.Data.SqliteClient.SqliteParameterCollection:get_Item
+(System.String parameterName)
+in <0x002af> Mono.Data.SqliteClient.SqliteCommand:Prepare ()
+in <0x00085> Mono.Data.SqliteClient.SqliteCommand:ExecuteReader
+(CommandBehavior behavior, Boolean want_results, System.Int32 rows_affected)
+in <0x0001d> Mono.Data.SqliteClient.SqliteCommand:ExecuteReader
+(CommandBehavior behavior)
+in <0x0000c> Mono.Data.SqliteClient.SqliteCommand:ExecuteReader ()
+in <0x000ca> Test:Main (System.String[] args)
+
+
+Expected Results:
+Clear run
+
+How often does this happen? 
+Always
+
+Additional Information:


More information about the mono-bugs mailing list