//Creates a SQL table from datatable information private void createDataTableToSQL(DataTable dt) { SQLPush sqlPush = new SQLPush(); sqlPush.createTableQuery(dt, true); sqlPush.insertToTable(dt); }
//Pushes the error to an SQL table public static void createError(String message, Exception e) { SQLPush sqlPush = new SQLPush(); if (!(errorCreated)) { //Creates datatable DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("error"); dt.Columns.Add("exception"); dt.Columns.Add("time"); //pushes the data to MS SQL dt.TableName = "ErrorLogs"; sqlPush.createTableQuery(dt, true); addToErrorTable(e, message, sqlPush); errorCreated = true; } else { addToErrorTable(e, message, sqlPush); } id++; }
public static void addToErrorTable(Exception e, String message, SQLPush sqlPush) { DateTime dateTime = new DateTime(); StringBuilder query = new StringBuilder(); query.Append("INSERT INTO ErrorLogs (id, error, exception, time) "); query.Append("VALUES ( " + id + " , " + message + " , " + "Exception message" + " , " + dateTime.ToString() + ")"); sqlPush.pushToSQL(query); }
//Puts all data from a datatable into the SQL private void dataTableToSQL(DataTable dt) { SQLPush sqlPush = new SQLPush(); sqlPush.insertToTable(dt); }