Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
cyq1162 committed Nov 14, 2017
1 parent f281baa commit 5a36ea9
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions DAL/DbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,16 +486,21 @@ private int ExeNonQuerySQL(string cmdText, bool isProc)
{
try
{

//else
//{
if (isUseUnsafeModeOnSqlite && !isProc && dalType == DalType.SQLite && !isOpenTrans)
if (useConnBean != connObject.Master)
{
_com.CommandText = "PRAGMA synchronous=Off;" + _com.CommandText;
recordsAffected = -2;//从库不允许执行非查询操作。
string msg = "You can't do ExeNonQuerySQL(with transaction or insert) on Slave DataBase!";
debugInfo.Append(msg + AppConst.BR);
WriteError(msg + (isProc ? "" : AppConst.BR + GetParaInfo(cmdText)));
}
else
{
if (isUseUnsafeModeOnSqlite && !isProc && dalType == DalType.SQLite && !isOpenTrans)
{
_com.CommandText = "PRAGMA synchronous=Off;" + _com.CommandText;
}
recordsAffected = _com.ExecuteNonQuery();
}
//rowCount = 1;
recordsAffected = _com.ExecuteNonQuery();
//}
}
catch (DbException err)
{
Expand Down Expand Up @@ -930,16 +935,6 @@ private void TestOpen()
debugInfo.Append(err.Message);
}
}
internal bool OpenCon()
{
bool result = OpenCon(connObject.Master);
if (_IsAllowRecordSql)
{
connObject.SetNotAllowSlave();
isAllowResetConn = false;
}
return result;
}

/// <summary>
/// 切换链接
Expand All @@ -954,6 +949,16 @@ private void ResetConn(ConnBean cb)//, bool isAllowReset
_con.ConnectionString = DalCreate.FormatConn(dalType, conn);
}
}
internal bool OpenCon()
{
bool result = OpenCon(connObject.Master);
if (_IsAllowRecordSql)
{
connObject.SetNotAllowSlave();
isAllowResetConn = false;
}
return result;
}
internal bool OpenCon(ConnBean cb)
{
try
Expand Down

0 comments on commit 5a36ea9

Please sign in to comment.