public static int updatesetting4newdb(int i_port, string str_usr, string str_pwd) { DbConnection dbConnection = null; DbCommand dbCommand = new OleDbCommand(); int result; try { dbConnection = new MySqlConnection(string.Concat(new object[] { "Database=", DBUrl.DB_CURRENT_NAME, ";Data Source=127.0.0.1;Port=", i_port, ";User Id=", str_usr, ";Password="******";Default Command Timeout=0;charset=utf8;" })); dbConnection.Open(); dbCommand = new MySqlCommand(); dbCommand.Connection = dbConnection; string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "sysdb.mdb;Jet OLEDB:Database Password=^tenec0Sensor"; OleDbCommand oleDbCommand = new OleDbCommand(); using (OleDbConnection oleDbConnection = new OleDbConnection(connectionString)) { try { oleDbConnection.Open(); oleDbCommand.Connection = oleDbConnection; oleDbCommand.CommandType = CommandType.Text; oleDbCommand.CommandText = string.Concat(new object[] { "update dbsource set db_type='MYSQL',db_name='eco',host_path='127.0.0.1',port= ", i_port, ",user_name = '", str_usr, "',pwd='", str_pwd, "' where active_flag = 2 " }); int num = oleDbCommand.ExecuteNonQuery(); if (num < 0) { result = -5; return(result); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); result = -5; return(result); } finally { oleDbCommand.Dispose(); } } DBConnPool.DisconnectDatabase(); DBUrl.initconfig(); result = 100; } catch (Exception ex2) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex2.Message + "\n" + ex2.StackTrace); result = -5; } finally { dbCommand.Dispose(); if (dbConnection != null) { dbConnection.Close(); } } return(result); }