常用的C#带参数SQLite数据库添加(插入)数据

        public bool InsertData(Model.ProgrammeModel model)
        {
            bool b = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into programme(");
            strSql.Append("dy,dl,xx,glys,pl,xh,fa,pinli,mdjx)");
            strSql.Append(" values (");
            strSql.Append("@dy,@dl,@xx,@glys,@pl,@xh,@fa,@pinli,@mdjx)");
            SQLiteParameter[] parameters = {
                    new SQLiteParameter("@dy", model.dy),
                    new SQLiteParameter("@dl", model.dl),
                    new SQLiteParameter("@xx", model.xx),
                    new SQLiteParameter("@glys", model.glys),
                    new SQLiteParameter("@pl", model.pl),
                    new SQLiteParameter("@xh", model.xh),
                    new SQLiteParameter("@fa", model.fa),
                    new SQLiteParameter("@pinli", model.pinli),
                    new SQLiteParameter("@mdjx", model.mdjx), };
            b = SQLiteHelper.ExecSQL(strSql.ToString(), parameters);
          //执行SQLite语句类库地址http://www.luofenming.com/show.aspx?id=ART2018020100001
            return b;
        }

评论