private void WriteEventToDatabase(LogEventInfo logEvent) { EnsureConnectionOpen(BuildConnectionString(logEvent)); var command = activeConnection.CreateCommand(); command.CommandText = CommandText.Render(logEvent); InternalLogger.Trace("Executing {0}: {1}", command.CommandType, command.CommandText); foreach (var par in Parameters) { var p = command.CreateParameter(); p.Direction = ParameterDirection.Input; if (par.Name != null) { p.ParameterName = par.Name; } if (par.Size != 0) { p.Size = par.Size; } if (par.Precision != 0) { p.Precision = par.Precision; } if (par.Scale != 0) { p.Scale = par.Scale; } var stringValue = par.Layout.Render(logEvent); p.Value = stringValue; command.Parameters.Add(p); InternalLogger.Trace(" Parameter: '{0}' = '{1}' ({2})", p.ParameterName, p.Value, p.DbType); } var result = command.ExecuteNonQuery(); InternalLogger.Trace("Finished execution, result = {0}", result); }