This commit is contained in:
sunkaixuan 2017-08-31 17:13:51 +08:00
parent 5c95784cac
commit bd5078e73f
5 changed files with 39 additions and 10 deletions

View File

@ -34,7 +34,7 @@ namespace SqlSugar
{
get
{
return ErrorMessage.GetThrowMessage("Connection open error . {0}", " 连接字符串出错了实在找不到原因请先Google错误.{0}.");
return ErrorMessage.GetThrowMessage("Connection open error . {0}", " 连接字符串出错了实在找不到原因请先Google错误{0}.");
}
}
}

View File

@ -17,12 +17,19 @@ namespace SqlSugar
{
if (base._DbConnection == null)
{
var mySqlConnectionString = base.Context.CurrentConnectionConfig.ConnectionString;
if (!mySqlConnectionString.ToLower().Contains("charset"))
try
{
mySqlConnectionString=mySqlConnectionString.Trim().TrimEnd(';') + ";charset=utf8;";
var mySqlConnectionString = base.Context.CurrentConnectionConfig.ConnectionString;
if (!mySqlConnectionString.ToLower().Contains("charset"))
{
mySqlConnectionString = mySqlConnectionString.Trim().TrimEnd(';') + ";charset=utf8;";
}
base._DbConnection = new MySqlConnection(mySqlConnectionString);
}
catch (Exception ex)
{
Check.Exception(true, ErrorMessage.ConnnectionOpen, ex.Message);
}
base._DbConnection = new MySqlConnection(mySqlConnectionString);
}
return base._DbConnection;
}

View File

@ -22,9 +22,17 @@ namespace SqlSugar
{
get
{
if (base._DbConnection == null)
try
{
base._DbConnection = new OracleConnection(base.Context.CurrentConnectionConfig.ConnectionString);
if (base._DbConnection == null)
{
base._DbConnection = new OracleConnection(base.Context.CurrentConnectionConfig.ConnectionString);
}
}
catch (Exception ex)
{
Check.Exception(true, ErrorMessage.ConnnectionOpen, ex.Message);
}
return base._DbConnection;
}

View File

@ -16,7 +16,14 @@ namespace SqlSugar
{
if (base._DbConnection == null)
{
base._DbConnection = new SqlConnection(base.Context.CurrentConnectionConfig.ConnectionString);
try
{
base._DbConnection = new SqlConnection(base.Context.CurrentConnectionConfig.ConnectionString);
}
catch (Exception ex)
{
Check.Exception(true, ErrorMessage.ConnnectionOpen, ex.Message);
}
}
return base._DbConnection;
}

View File

@ -17,8 +17,15 @@ namespace SqlSugar
{
if (base._DbConnection == null)
{
var SQLiteConnectionString = base.Context.CurrentConnectionConfig.ConnectionString;
base._DbConnection = new SQLiteConnection(SQLiteConnectionString);
try
{
var SQLiteConnectionString = base.Context.CurrentConnectionConfig.ConnectionString;
base._DbConnection = new SQLiteConnection(SQLiteConnectionString);
}
catch (Exception ex)
{
Check.Exception(true, ErrorMessage.ConnnectionOpen, ex.Message);
}
}
return base._DbConnection;
}