SVN r1061
SVN-Revision: r1061
This commit is contained in:
+23
-32
@@ -20,6 +20,7 @@ using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Lskj.Core
|
||||
{
|
||||
@@ -178,7 +179,7 @@ namespace Lskj.Core
|
||||
DataBase = subKey.GetValue("datastr", "") + "";
|
||||
ServerName = subKey.GetValue("ServerName", "") + "";
|
||||
InternalNetworkAddress = subKey.GetValue("InternalNetworkAddress", "") + "";
|
||||
ExternalNetworkAddress= subKey.GetValue("ExternalNetworkAddress", "") + "";
|
||||
ExternalNetworkAddress = subKey.GetValue("ExternalNetworkAddress", "") + "";
|
||||
|
||||
IsInternalNetwork = (subKey.GetValue("IsInternalNetwork", "") + "").Equals("1");
|
||||
LoginName = subKey.GetValue("LoginName", "") + "";
|
||||
@@ -383,37 +384,27 @@ namespace Lskj.Core
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool CreateConnection(string Connection = "")
|
||||
public bool CreateConnection(string Connection = "", ConnectionType connectionType = ConnectionType.SqlServer)
|
||||
{
|
||||
|
||||
string connStr = GetConnection(Connection);
|
||||
if (SqlHelper._connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlHelper._connection.Close();
|
||||
SqlHelper._connection.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
SqlHelper._connection = null;
|
||||
}
|
||||
bool isConnect = false;
|
||||
try
|
||||
{
|
||||
SqlHelper._connection = new SqlConnection(connStr);
|
||||
SqlHelper._connection.Open();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteLog(ex.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
string connStr = GetConnection(Connection);
|
||||
//connectionType = ConnectionType.KdbnServer;
|
||||
//connStr = "host=192.168.0.55;port=54321;database=test3;username=lserpAdmin;password=lserp110;";
|
||||
//connectionType = ConnectionType.DmServer;
|
||||
//connStr = "Server=192.168.0.55:5236; schema=DBO; UserId=LSERPADMIN; PWD=Lserp110";
|
||||
string providerName = "System.Data.SqlClient";
|
||||
SqlHelper.ConnectionType = ConnectionType.SqlServer;
|
||||
if (connectionType == ConnectionType.KdbnServer)
|
||||
{
|
||||
providerName = "Kdbndp";
|
||||
SqlHelper.ConnectionType = ConnectionType.KdbnServer;
|
||||
}
|
||||
else if (connectionType == ConnectionType.DmServer)
|
||||
{
|
||||
providerName = "Dm";
|
||||
SqlHelper.ConnectionType = ConnectionType.DmServer;
|
||||
}
|
||||
SqlHelper.dbFactory = DbProviderFactories.GetFactory(providerName);
|
||||
|
||||
Reference in New Issue
Block a user