public HistoryRefreshOleDb() { tables = new List <Table>(); Table table; oleDbConnection = new OleDbConnection(); oleDbConnection.ConnectionString = DataConfig.oledbConnectLineBegin + DataConfig.localDatabase + DataConfig.oledbConnectLineEnd + DataConfig.oledbConnectPass; oleDbCommand = new OleDbCommand("SELECT [id], [name], [represent], [datetime], [error], [user] FROM History", oleDbConnection); try{ oleDbConnection.Open(); oleDbDataReader = oleDbCommand.ExecuteReader(); while (oleDbDataReader.Read()) { table.name = oleDbDataReader["name"].ToString(); table.represent = oleDbDataReader["represent"].ToString(); table.datetime = oleDbDataReader["datetime"].ToString(); table.error = oleDbDataReader["error"].ToString(); table.user = oleDbDataReader["user"].ToString(); tables.Add(table); } oleDbDataReader.Close(); oleDbConnection.Close(); }catch (Exception ex) { Utilits.Console.Log("[ОШИБКА] " + ex.Message, false, true); if (oleDbDataReader != null) { oleDbDataReader.Close(); } if (oleDbConnection != null) { oleDbConnection.Close(); } return; } oleDb = new OleDb(DataConfig.localDatabase); oleDb.oleDbCommandSelect.CommandText = "SELECT [id], [name], [represent], [datetime], [error], [user] FROM History"; oleDb.oleDbCommandUpdate.CommandText = "UPDATE History SET " + "[name] = @name, " + "[represent] = @represent, " + "[datetime] = @datetime, " + "[error] = @error, " + "[user] = @user " + "WHERE ([id] = @id)"; oleDb.oleDbCommandUpdate.Parameters.Add("@name", OleDbType.VarChar, 255, "name"); oleDb.oleDbCommandUpdate.Parameters.Add("@represent", OleDbType.VarChar, 255, "represent"); oleDb.oleDbCommandUpdate.Parameters.Add("@datetime", OleDbType.VarChar, 255, "datetime"); oleDb.oleDbCommandUpdate.Parameters.Add("@error", OleDbType.VarChar, 255, "error"); oleDb.oleDbCommandUpdate.Parameters.Add("@user", OleDbType.VarChar, 255, "user"); oleDb.oleDbCommandUpdate.Parameters.Add("@id", OleDbType.Integer, 10, "id"); if (!oleDb.ExecuteFill("History")) { Utilits.Console.Log("[МОНИТОРИНГ:ПРЕДУПРЕЖДЕНИЕ] История обновлений базы данных не загружена!"); } }
public HistoryRefreshOleDb() { oleDb = new OleDb(DataConfig.localDatabase); oleDb.oleDbCommandSelect.CommandText = "SELECT [id], [name], [represent], [datetime], [error], [user] FROM History"; oleDb.oleDbCommandUpdate.CommandText = "UPDATE History SET " + "[name] = @name, " + "[represent] = @represent, " + "[datetime] = @datetime, " + "[error] = @error, " + "[user] = @user " + "WHERE ([id] = @id)"; oleDb.oleDbCommandUpdate.Parameters.Add("@name", OleDbType.VarChar, 255, "name"); oleDb.oleDbCommandUpdate.Parameters.Add("@represent", OleDbType.VarChar, 255, "represent"); oleDb.oleDbCommandUpdate.Parameters.Add("@datetime", OleDbType.VarChar, 255, "datetime"); oleDb.oleDbCommandUpdate.Parameters.Add("@error", OleDbType.VarChar, 255, "error"); oleDb.oleDbCommandUpdate.Parameters.Add("@user", OleDbType.VarChar, 255, "user"); oleDb.oleDbCommandUpdate.Parameters.Add("@id", OleDbType.Integer, 10, "id"); if (oleDb.ExecuteFill("History")) { tables = new List <Table>(); Table table; foreach (DataRow row in oleDb.dataSet.Tables["History"].Rows) { table.name = row["name"].ToString(); table.represent = row["represent"].ToString(); table.datetime = row["datetime"].ToString(); table.error = row["error"].ToString(); table.user = row["user"].ToString(); tables.Add(table); } } else { Utilits.Console.Log("[ПРЕДУПРЕЖДЕНИЕ] Служба истории обновлений базы данных не запущена!!!"); } }