|
|
@@ -17,8 +17,7 @@ namespace UAS_MES.DataOperate
|
|
|
//用户选择的数据库的连接字符串
|
|
|
public static string DBConnectionString;
|
|
|
public static OracleConnection connection = null;
|
|
|
- OracleCommand command = null;
|
|
|
- int ReconnectTime = 0;
|
|
|
+ OracleCommand command = new OracleCommand();
|
|
|
/// <summary>
|
|
|
/// 执行构造函数的时候打开数据库的链接
|
|
|
/// </summary>
|
|
|
@@ -32,11 +31,20 @@ namespace UAS_MES.DataOperate
|
|
|
else
|
|
|
connection = new OracleConnection(DBConnectionString);
|
|
|
connection.Open();
|
|
|
- command = new OracleCommand();
|
|
|
command.Connection = connection;
|
|
|
command.CommandTimeout = 0;
|
|
|
}
|
|
|
- catch (Exception e) { LogManager.DoLog(e.Message); }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ if (DBConnectionString == null || DBConnectionString == ConnectionStrings)
|
|
|
+ connection = new OracleConnection(ConnectionStrings);
|
|
|
+ else
|
|
|
+ connection = new OracleConnection(DBConnectionString);
|
|
|
+ connection.Open();
|
|
|
+ command.Connection = connection;
|
|
|
+ command.CommandTimeout = 0;
|
|
|
+ LogManager.DoLog(e.Message);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -417,7 +425,7 @@ namespace UAS_MES.DataOperate
|
|
|
ad.UpdateCommand = command;
|
|
|
ad.Update(DataTable);
|
|
|
ad.Dispose();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -898,7 +906,7 @@ namespace UAS_MES.DataOperate
|
|
|
}
|
|
|
for (int i = 0; i < command.Parameters.Count; i++)
|
|
|
param[i] = command.Parameters[i].Value.ToString();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1048,8 +1056,10 @@ namespace UAS_MES.DataOperate
|
|
|
|
|
|
public void Dispose()
|
|
|
{
|
|
|
- command.Dispose();
|
|
|
- connection.Dispose();
|
|
|
+ if (command != null)
|
|
|
+ command.Dispose();
|
|
|
+ if (connection != null)
|
|
|
+ connection.Dispose();
|
|
|
}
|
|
|
|
|
|
private void Reconnect(OracleCommand cmd)
|