public void CreateTable(string dbPath) { if (File.Exists(dbPath)) { File.Delete(dbPath); } SqlDb db = new SQLiteDb(_connString); db.IsShowSqlToConsole = _isShowSqlToConsole; var sql = "create table UserInfo(UserId int not null,UserName varchar(50),Age int,Email varchar(50))"; var result = db.ExecuteNoneQuery(sql, null); }
/// <summary> /// 执行非查询操作 /// </summary> public void OrtherNoneQuery() { SqlDb db = new SQLiteDb(_connString); db.IsShowSqlToConsole = _isShowSqlToConsole; var dbFactory = db.DbBuilder.DbFactory; var dbOperator = dbFactory.GetDbParamOperator(); var sql = ""; var paramSql = string.Format("delete from UserInfo where UserId={0}UserId", dbOperator); //根据SQL语句、参数列表删除数据用法1 sql = "delete from UserInfo where UserId=16"; var result = db.ExecuteNoneQuery(sql, null); var dbParams = new List <IDbDataParameter>(); dbParams.Add(dbFactory.GetDbParam("UserId", 17)); result = db.ExecuteNoneQuery(paramSql, dbParams); //根据SQL语句、object参数列表删除数据用法2 sql = "delete from UserInfo where UserId=18"; result = db.ExecuteNoneQueryWithObjParam(sql); result = db.ExecuteNoneQueryWithObjParam(paramSql, new { UserId = 19 }); }