/// <summary>
        /// Adds the given Lemma to the repository. The Id of the lemma is autogenerated.
        /// </summary>
        /// <param name="val"></param>
        public void Add(T val)
        {
            InsertCmd.Parameters.Add(Database.CreateParameter("@word", val.Word, InsertCmd));
            object[] rec = ConstructRecordFrom(val);
            for (int i = 0; i < ColumNames.Count(); ++i)
            {
                InsertCmd.Parameters.Add(Database.CreateParameter("@" + ColumNames[i], rec[i], InsertCmd));
            }
            int id = InsertCmd.ExecuteNonQuery();

            val.Id = id;
        }
Beispiel #2
0
        public int InsertBySql(string _insertSql)
        {
            this.InsertCmd = InitSqlCommand(_insertSql, this.InsertCmd);

            try
            {
                InsertCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(4);
            }

            return(0);
        }