Hi,

Here's my scenario:

Win7 command prompt:
$ sqlite3 temp.db
SQLite version 3.7.10 2012-01-16 13:28:40
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t(a,b,c,d);
sqlite>.quit

>From C# program:

private static void Main()
{
    using (var connection = new SQLiteConnection("data source=temp.db"))
    using (var command = new SQLiteCommand(connection))
    {
        command.CommandText = "INSERT INTO [t]([a],[b],[c],[d]) 
VALUES(?1,?2,?3,?4)";        command.Parameters.Add(new SQLiteParameter {Value 
= 1});
        command.Parameters.Add(new SQLiteParameter {Value = 2});
        command.Parameters.Add(new SQLiteParameter {Value = 3});
        command.Parameters.Add(new SQLiteParameter {Value = 4});        
connection.Open();
        command.ExecuteNonQuery();
    }
}

when I run the program, I get following excetion:

Unhandled Exception: System.Data.SQLite.SQLiteException: SQLite error
Insufficient parameters supplied to the command
   at System.Data.SQLite.SQLiteStatement.BindParameter(Int32 index, 
SQLiteParameter param)
   at System.Data.SQLite.SQLiteStatement.BindParameters()
   at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
   at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
   at System.Data.SQLite.SQLiteDataReader.NextResult()
   at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, 
CommandBehavior behave)
   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()

The same works fine if the command is just: INSERT INTO [t]([a],[b],[c],[d]) 
VALUES(?,?,?,?)

However I need to be able to specify argument numbers explicitly in some cases.

Did I miss something or is this a bug?

Thanks,
 - Levi                                           
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to