Main Site Documentation

SQLite


#1

hi,

i am not an expert on database this is my first time, i have this function

        /// <summary>
        /// Inser a item into database
        /// </summary>
        public void Insert(string table, int dependency, char completed)
        {
            Debug.Print("INSERT INTO " + table + "(DEPENDENCYID, COMPLETED) " +
                "VALUES(" + dependency + ", " + completed + ")");

            dataBase.ExecuteNonQuery("INSERT INTO " + table + "(DEPENDENCYID, COMPLETED) " + 
                "VALUES(" + dependency + ", " + completed + ")");
        }

i use it like this

database.Insert("PINNEN", 1, 'N');

i get a error: Additional information: no such column: N
can someone help me? why this throws a error.


#2

You are missing single quotes for the completed value in your insert statement.


  /// <summary>
        /// Inser a item into database
        /// </summary>
        public void Insert(string table, int dependency, char completed)
        {
            Debug.Print("INSERT INTO " + table + "(DEPENDENCYID, COMPLETED) " +
                "VALUES(" + dependency + ", " + completed + ")");
 
            dataBase.ExecuteNonQuery("INSERT INTO " + table + "(DEPENDENCYID, COMPLETED) " + 
                "VALUES(" + dependency + ", '" + completed + "')");
        }

I have a helper wrapper that can be useful for you:

http://code.tinyclr.com/project/192/sqlite-wrapper/


#3

Yeah 8)