private void button1_Click(object sender, EventArgs e) { LogEntry le = new LogEntry(); le.LogEntrySeverity = 7; le.LogEntrymessage = "test"; le.LogEntryDateCreated = DateTime.Now; le.LogEntryError = "a"; le.LogEntrySource = "source"; Logger CL = new Logger(LogDatabaseTypes.SqlServer); CL.Write(le); this.logFileTableAdapter.Fill(this.customLoggerDataSet.LogFile); }
public override void Write(LogEntry logEvent) { try { using (SqlConnection sqlConn = new SqlConnection(sqlConnString)) using (SqlCommand sqlCommand = new SqlCommand("INSERT INTO " + tableName + " values (@LogEntrymessage,@LogEntrySeverity,@LogEntryError,@LogEntrySource,@LogEntryDateCreated)", sqlConn)) { sqlCommand.Parameters.Add(new SqlParameter("@LogEntrymessage", logEvent.LogEntrymessage)); sqlCommand.Parameters.Add(new SqlParameter("@LogEntrySeverity", logEvent.LogEntrySeverity)); sqlCommand.Parameters.Add(new SqlParameter("@LogEntryError", logEvent.LogEntryError)); sqlCommand.Parameters.Add(new SqlParameter("@LogEntrySource", logEvent.LogEntrySource)); sqlCommand.Parameters.Add(new SqlParameter("@LogEntryDateCreated", logEvent.LogEntryDateCreated)); sqlConn.Open(); sqlCommand.ExecuteNonQuery(); sqlConn.Close(); } } catch (SqlException ex ) { throw ex ; } }
public void Write(LogEntry le) { _dal.Write(le); }
public abstract void Write(LogEntry log);
public override void Write(LogEntry log) { throw new NotImplementedException(); }