public int GetCurrentSid(string tableName) { try { string connectionString = new DBConnectionString().ToString(); this.conn = new MySqlConnection(connectionString); this.conn.Open(); this.cmd = this.conn.CreateCommand(); string query = string.Format("select max(Sid) from {0} ", tableName); this.cmd.CommandText = query; using (var reader = this.cmd.ExecuteReader()) { if (reader.Read()) { int sid = reader.GetInt32(0); return sid; } } conn.Close(); } catch (Exception e) { Debug.WriteLine(e.Message); } return 1; }
internal MySqlConnection GetDBConnection() { string connectionString = new DBConnectionString().ToString(); var conn = new MySqlConnection(connectionString); conn.Open(); return conn; }
private void Initialize() { string connectionString = new DBConnectionString().ToString(); this.conn = new MySqlConnection(connectionString); this.conn.Open(); this.cmd = this.conn.CreateCommand(); }
/// <summary> /// /// </summary> public DBDataProvider() { this.allDeviceKeys.Add(DeviceKey_Hpic); this.allDeviceKeys.Add(DeviceKey_Dwd); this.allDeviceKeys.Add(DeviceKey_HvSampler); this.allDeviceKeys.Add(DeviceKey_ISampler); this.allDeviceKeys.Add(DeviceKey_NaI); this.allDeviceKeys.Add(DeviceKey_Shelter); this.allDeviceKeys.Add(DeviceKey_Weather); this.FetchCount = 26; this.dataListeners = new Dictionary<string, DBDataCommonListerner>(30); // 192.168.1.24 string installPath = Assembly.GetExecutingAssembly().Location; string fileName = string.Format("{0}\\..\\local.ip", installPath); var s = new DBConnectionString(); s.Address = "127.0.0.1"; if (File.Exists(fileName)) { using (StreamReader sr = new StreamReader(fileName)) { string ip = sr.ReadLine(); if (ip != null && ip.Length > 0) { s.Address = ip; } } } this.ConnectionString = s.ToString(); this.conn = new MySqlConnection(this.ConnectionString); if (this.conn != null) { try { this.conn.Open(); this.cmd = this.conn.CreateCommand(); } catch (Exception e) { string msg = e.Message; } } // 192.168.1.24 this.timelineSource = new List<Dictionary<string, object>>(); }
/// <summary> /// /// </summary> private DBDataSource() { try { string connectionString = new DBConnectionString().ToString(); this.conn = new MySqlConnection(connectionString); this.conn.Open(); this.cmd = this.conn.CreateCommand(); } catch (Exception e) { string msg = e.Message; } }
internal void Import() { var connectionString = new DBConnectionString().ToString(); using (var connToMySql = new MySqlConnection(connectionString)) { connToMySql.Open(); MySqlCommand cmd = connToMySql.CreateCommand(); string sql = string.Format("LOAD DATA INFILE '{0}' IGNORE INTO TABLE scada.hpic_rec FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' lines terminated by '\n' (time,Doserate,Highvoltage,Battery,Temperature);", this.csvFile); cmd.CommandText = sql; cmd.ExecuteNonQuery(); } }
internal void CreateDAQDB() { var s = new DBConnectionString(); s.Database = "mysql"; this.connectionString = new DBConnectionString().ToString(); using (var connToMySql = new MySqlConnection(this.connectionString)) { connToMySql.Open(); MySqlCommand cmd = connToMySql.CreateCommand(); cmd.CommandText = "CREATE DATABASE if NOT EXISTS scada"; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public void Connect() { try { string connectionString = new DBConnectionString().ToString(); this.conn = new MySqlConnection(connectionString); this.conn.Open(); this.cmd = this.conn.CreateCommand(); } catch (Exception e) { RecordManager.DoSystemEventRecord(Device.Main, e.Message, RecordType.Error); // disable RetryConnection by Kaikai //this.RetryConnection(e); } }
public MySqlConnection CreateMySqlConnection() { string connectionString = new DBConnectionString().ToString(); return new MySqlConnection(connectionString); }
public void Connect() { try { string connectionString = new DBConnectionString().ToString(); this.conn = new MySqlConnection(connectionString); this.conn.Open(); this.cmd = this.conn.CreateCommand(); // AddHPICRecordData("243.5", "2.3", "5.88", "24.0000", 2); // AddHPICRecordData("243.5", "2.3", "5.88", "24.0000", 2); } catch (Exception e) { Debug.WriteLine(e.Message); } }
public MySqlConnection GetMySqlConnection() { string installPath = Assembly.GetExecutingAssembly().Location; string fileName = string.Format("{0}\\..\\local.ip", installPath); var s = new DBConnectionString(); s.Address = "127.0.0.1"; if (File.Exists(fileName)) { using (StreamReader sr = new StreamReader(fileName)) { string ip = sr.ReadLine(); if (ip != null && ip.Length > 0) { s.Address = ip; } } } this.ConnectionString = s.ToString(); var conn = new MySqlConnection(this.ConnectionString); if (conn != null) { try { conn.Open(); return conn; } catch (Exception e) { string msg = e.Message; } } return null; }