public void GetData(string sql, string connectionKey) { var formattedSQL = FormatSQL(sql, connectionKey); Log4Net.SqlStatementStack.Push(new Log4Net.SqlStatementStackMessage(formattedSQL)); Log4Net.LogDebug(formattedSQL, connectionKey); var connectionString = StartUp.GetConnectionString(connectionKey); DBTable = new DataTable(); using (var connection = new SqlConnection(connectionString)) { //var conn = new ProfiledDbConnection(connection, MiniProfiler.Current) var dbCommand = new SqlCommand(sql, connection); dbCommand.CommandTimeout = StartUp.TimeOut; var dbAdapter = new SqlDataAdapter(dbCommand); //var prdataAdapter = new ProfiledDbDataAdapter(DBAdapter); DBTable.BeginLoadData(); dbAdapter.Fill(DBTable); DBTable.EndLoadData(); DBTable.CaseSensitive = false; connection.Close(); } DBDataSet.LogResultCount(DBTable); #region log exception if (!sql.StartsWith("exec AuditDetailInsert") && !sql.StartsWith("exec AuditSummaryUpdate") && !sql.StartsWith("exec AuditSummaryInsert")) { DBDataReader.MessageLog("SQL: " + formattedSQL); } #endregion log exception }
public void GetData(string sql, string connectionKey) { var formattedSql = DBDataTable.FormatSql(sql); Log4Net.SqlStatementStack.Push(new Log4Net.SqlStatementStackMessage(formattedSql)); Log4Net.LogDebug(formattedSql, connectionKey); var connectionString = StartUp.GetConnectionString(connectionKey); using (var connection = new SqlConnection(connectionString)) { var dataAdapter = new SqlDataAdapter(formattedSql, connection); dataAdapter.Fill(DBDataset); DBDataset.CaseSensitive = false; } LogResultCount(DBDataset); if (!sql.StartsWith("exec AuditDetailInsert") && !sql.StartsWith("exec AuditSummaryUpdate") && !sql.StartsWith("exec AuditSummaryInsert")) { DBDataReader.MessageLog("SQL: " + sql); } }
public DataAccessBase(string key) { _connectionString = StartUp.GetConnectionString(key); }