Parameters in v. 0.12

2004-04-01
2004-04-02
  • Nobody/Anonymous

    I used the following code in v. 0.9

            public static IDataReader ExecuteReader(string connectionString, string commandText, params object[] parameters)
            {
                SQLiteConnection conn = new SQLiteConnection();
                conn.ConnectionString = connectionString;
                conn.Open();
                try
                {
                    SQLiteCommand cmd = conn.CreateCommand();
                    cmd.CommandText = commandText;
                    for (int i = 0; i < parameters.Length; i++)
                    {
                        cmd.Parameters[i].Value = parameters[i];
                    }
                    return cmd.ExecuteReader();
                }
                catch
                {
                    conn.Close();
                    throw;
                }
            }

    This code however does not work in 0.12, I get an exception when assigning the parameter in the for loop.

    The sql statement sent to the function uses unnamed parameters (e.g. "select * from table where id = ?") and the parameters that are supposed to be inserted are sent in the params array.

     
    • Nobody/Anonymous

      See the release notes for 0.12, your issue is addressed in the very first item...

       
      • Nobody/Anonymous

        ahh, ok - I didnt read the release notes.

        thanks :)

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks