/// <summary> /// Executes the sql query and returns the number of rows. /// </summary> /// <returns>int</returns> /// <param name="sql">string</param> public SQLQueryResult ExecuteQuery(string sql) { SqliteCommand command = new SqliteCommand(sql, conn); SQLDataTable dataTable = new SQLDataTable(); SqliteDataReader sqliteDataReader = command.ExecuteReader(); dataTable = new SQLDataTable("Result"); dataTable = dataTable.LoadWithoutConstraints(sqliteDataReader, "Result"); return(new SQLQueryResult(sql, dataTable)); }
/// <summary> /// Load the specified reader, loadOption and errorHandler. /// </summary> /// <param name="reader">IDataReader</param> /// <param name="tableName">string</param> public SQLDataTable LoadWithoutConstraints(IDataReader reader, string tableName) { SQLDataTable temp = new SQLDataTable(); using (DataSet ds = new DataSet() { EnforceConstraints = false }) { ds.Tables.Add(temp); temp.Load(reader, LoadOption.OverwriteChanges); ds.Tables.Remove(temp); temp.TableName = tableName; } return(temp); }
/// <summary> /// Initializes a new instance of the <see cref="T:StatusQuoBaseball.Database.SQLQueryResult"/> class. /// </summary> /// <param name="sqlStatement">string</param> ///<param name="dataTable">SQLDataTable</param> public SQLQueryResult(string sqlStatement, SQLDataTable dataTable) : base(dataTable.Rows.Count, sqlStatement) { this.dataTable = dataTable; }