Named parameters are implemented

2004-03-29
2004-04-03
  • Alexander Gavrilov

    Named parameters are implemented. They are very similar to SqlParameter in System.Data.SqlClient namespace.

    The usage pattern for the named parameters follows:

    IDbConnection conn = new SQLiteConnection("...");
    IDbCommand cmd = conn.CreateCommand();
    cmd.CommandText = "SELECT * FROM T WHERE a=@a";

    IDbDataParameter p = cmd.CreateParameter();
    p.ParameterName = "@a";
    p.Value = 1l

    cmd.Parameters.Add(p);

     
    • Wilson Chan

      Wilson Chan - 2004-04-02

      the detail changes?

       
    • Wilson Chan

      Wilson Chan - 2004-04-03

      can we access the fields using something like: getstring("username"),getinteger("age") rather than getwstring(0), getinteger(1)... ?

       
      • Alexander Gavrilov

        SQLiteDataReader is merely the implementation of IDataReader interface. I wouldn't add those functions to SQLiteDataReader. I can recommend more generic approach and use only interface methods in your code:

        void SumFunction( IDbConnection conn )
        {
            IDbCommand cmd = conn.CreateCommand();
            cmd.CommandText = "some sql";
            IDataReader rd = cmd.ExecuteReader();

            // first method
            string f1 = rd.GetString(rd.GetOridinal("fieldName"));

            // second method
            string f2 = Convert.ToString(rd["fieldName"]);   
        }

        That way your code will not depend on the type of connection at all. You can easily pass either SQLiteConnection or OleDbConnection to this function.

         
        • Alexander Gavrilov

          Sorry, it must be rd.GetOrdinal instead of rd.GetOridinal

           
    • Wilson Chan

      Wilson Chan - 2004-04-03

      rd["fieldName"] is something like what I want, thanx!

       

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

Sign up for the SourceForge newsletter:





No, thanks