fixed utf8mb3 error

master
Don Oerkfitz 3 years ago
parent 07990080ed
commit 18c4efdcd2

@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.26" />
<PackageReference Include="MySql.Data" Version="8.0.25" />
<PackageReference Include="Quartz" Version="3.3.3" />
<PackageReference Include="Quartz.Jobs" Version="3.3.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />

@ -14,22 +14,22 @@ namespace Common.Library.SQL.Base
}
public struct DBConnectionInformation
{
public string DBHost {get;set;}
public string DBName {get;set;}
public string DBUserName {get;set;}
public string DBPassword {get;set;}
public DBType DBType {get;set;}
public string DBHost { get; set; }
public string DBName { get; set; }
public string DBUserName { get; set; }
public string DBPassword { get; set; }
public DBType DBType { get; set; }
public string GetConnectionString()
{
string rv = string.Empty;
switch(DBType)
switch (DBType)
{
case DBType.MSSQL:
break;
case DBType.MYSQL:
rv = string.Format("Server={0};Database={1};Uid={2};Pwd={3};SslMode=none", DBHost, DBName, DBUserName, DBPassword);
rv = string.Format("Server={0};Database={1};Uid={2};Pwd={3};", DBHost, DBName, DBUserName, DBPassword);
break;
}

@ -8,9 +8,9 @@ namespace Common.Library.SQL.MySQL
{
public class MySQL : SQLBase
{
protected MySqlConnection DBConnection {get;set;}
protected MySqlCommand DBCommand {get;set;}
protected MySqlDataReader DBReader {get;set;}
protected MySqlConnection DBConnection { get; set; }
protected MySqlCommand DBCommand { get; set; }
protected MySqlDataReader DBReader { get; set; }
public MySQL(string server, string database, string username, string password)
{
@ -34,11 +34,15 @@ namespace Common.Library.SQL.MySQL
DBConnection = new MySqlConnection(DBConnectionInfo.GetConnectionString());
DBConnection.Open();
DBCommand = DBConnection.CreateCommand();
DBCommand.CommandType = CommandType.Text;
DBCommand.CommandText = "SET character_set_results=utf8mb4";
DBCommand.ExecuteNonQuery();
}
protected override void DisposeConnection()
{
if(DBConnection.State == ConnectionState.Open)
if (DBConnection.State == ConnectionState.Open)
{
DBConnection.Close();
}
@ -53,7 +57,7 @@ namespace Common.Library.SQL.MySQL
{
int? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetInt32(columnID);
}
@ -70,7 +74,7 @@ namespace Common.Library.SQL.MySQL
{
byte? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetByte(columnID);
}
@ -119,7 +123,7 @@ namespace Common.Library.SQL.MySQL
{
decimal? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetDecimal(columnID);
}
@ -136,7 +140,7 @@ namespace Common.Library.SQL.MySQL
{
long? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetInt64(columnID);
}
@ -153,7 +157,7 @@ namespace Common.Library.SQL.MySQL
{
short? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetInt16(columnID);
}
@ -170,7 +174,7 @@ namespace Common.Library.SQL.MySQL
{
string rv = string.Empty;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetString(columnID);
}
@ -187,7 +191,7 @@ namespace Common.Library.SQL.MySQL
{
bool? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = DBReader.GetBoolean(columnID);
}
@ -204,7 +208,7 @@ namespace Common.Library.SQL.MySQL
{
DateTime? rv = null;
if(!DBReader.IsDBNull(columnID))
if (!DBReader.IsDBNull(columnID))
{
rv = GetDateTime(columnID);
}

Loading…
Cancel
Save