public async Task <string> ExecSqlAsync(List <ParamSql> lst) { string result; try { using (this.conn = new SQLiteConnection(this._connectionString)) { bool flag = this.conn.State != ConnectionState.Open; if (flag) { await this.conn.OpenAsync(); } SQLiteTransaction sqliteTransaction = this.conn.BeginTransaction(); try { this.cmd = new SQLiteCommand { CommandType = CommandType.Text, Connection = this.conn, Transaction = sqliteTransaction }; foreach (ParamSql paramSql in lst) { this.cmd.CommandText = paramSql.Sql; foreach (SqlHelperParameter sqlHelperParameter in paramSql.Params) { this.cmd.Parameters.Add(this.GetParameter(sqlHelperParameter)); } await this.cmd.ExecuteNonQueryAsync(); } await sqliteTransaction.CommitAsync(); result = string.Empty; } catch (Exception ex) { await sqliteTransaction.RollbackAsync(); result = ex.Message; } finally { await sqliteTransaction.DisposeAsync(); await this.cmd.DisposeAsync(); await this.conn.CloseAsync(); } } } catch (Exception ex2) { result = ex2.Message; } return(result); }
public async Task <string> ExecSqlAsync(ArrayList sqlList) { string result; using (this.conn = new SQLiteConnection(this._connectionString)) { bool flag = this.conn.State != ConnectionState.Open; if (flag) { await this.conn.OpenAsync(); } SQLiteTransaction sqliteTransaction = this.conn.BeginTransaction(); try { this.cmd = new SQLiteCommand { CommandType = CommandType.Text, Connection = this.conn }; foreach (object obj in sqlList) { string commandText = (string)obj; this.cmd.CommandText = commandText; await this.cmd.ExecuteNonQueryAsync(); } await sqliteTransaction.CommitAsync(); result = string.Empty; } catch (Exception ex) { await sqliteTransaction.RollbackAsync(); result = ex.Message; } finally { await sqliteTransaction.DisposeAsync(); } } return(result); }