Skip to content

无法添加内容和导入内容 #843

Open

Description

@russellyi
Incorrect string value: '\xE5\xAD\xA6\xE6\xA0\xA1...' for column 'Title' at row 1

在 MySql.Data.MySqlClient.MySqlStream.ReadPacket() 
在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) 
在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) 
在 MySql.Data.MySqlClient.MySqlDataReader.NextResult() 
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) 
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() 
在 SiteServer.CMS.Data.DbHelper.ExecuteNonQuery(IDbCommand command) 
在 SiteServer.CMS.Data.DbHelper.ExecuteNonQuery(IDbTransaction transaction, String commandText, IDataParameter[] commandParameters) 
在 SiteServer.CMS.Data.DbHelper.ExecuteNonQueryAndReturnId(String tableName, String idColumnName, IDbTransaction trans, String commandText, IDataParameter[] commandParameters) 
在 SiteServer.CMS.Data.DbHelper.ExecuteNonQueryAndReturnId(String tableName, String idColumnName, String connectionString, String commandText, IDataParameter[] commandParameters) 
在 SiteServer.CMS.Data.DataProviderBase.ExecuteNonQueryAndReturnId(String tableName, String idColumnName, String commandText, IDataParameter[] commandParameters) 
在 SiteServer.CMS.Provider.ContentDao.Insert(String tableName, IContentInfo contentInfo) 
在 SiteServer.CMS.Provider.ContentDao.Insert(String tableName, SiteInfo siteInfo, IContentInfo contentInfo, Boolean isUpdateContentNum, Int32 taxis) 
在 SiteServer.CMS.Provider.ContentDao.Insert(String tableName, SiteInfo siteInfo, IContentInfo contentInfo) 在 SiteServer.BackgroundPages.Cms.PageContentAdd.Submit_OnClick(Object sender, EventArgs e)

2018-06-11 17:50:37

Activity

  1. russellyi commented on Jun 11, 2018

    @russellyi
    Author

    为什么创建的表默认字符集是latin1,改成utf8就可以添加内容了。

    CREATE TABLE `model_content` (
      `Id` int(11) NOT NULL AUTO_INCREMENT,
      `ChannelId` int(11) DEFAULT NULL,
      `SiteId` int(11) DEFAULT NULL,
      `AddUserName` varchar(255) DEFAULT NULL,
      `LastEditUserName` varchar(255) DEFAULT NULL,
      `WritingUserName` varchar(255) DEFAULT NULL,
      `LastEditDate` datetime DEFAULT NULL,
      `Taxis` int(11) DEFAULT NULL,
      `GroupNameCollection` varchar(255) DEFAULT NULL,
      `Tags` varchar(255) DEFAULT NULL,
      `SourceId` int(11) DEFAULT NULL,
      `ReferenceId` int(11) DEFAULT NULL,
      `IsChecked` varchar(18) DEFAULT NULL,
      `CheckedLevel` int(11) DEFAULT NULL,
      `Hits` int(11) DEFAULT NULL,
      `HitsByDay` int(11) DEFAULT NULL,
      `HitsByWeek` int(11) DEFAULT NULL,
      `HitsByMonth` int(11) DEFAULT NULL,
      `LastHitsDate` datetime DEFAULT NULL,
      `SettingsXml` longtext,
      `Title` varchar(255) DEFAULT NULL,
      `IsTop` varchar(18) DEFAULT NULL,
      `IsRecommend` varchar(18) DEFAULT NULL,
      `IsHot` varchar(18) DEFAULT NULL,
      `IsColor` varchar(18) DEFAULT NULL,
      `LinkUrl` varchar(200) DEFAULT NULL,
      `AddDate` datetime DEFAULT NULL,
      `SubTitle` varchar(255) DEFAULT NULL,
      `ImageUrl` varchar(200) DEFAULT NULL,
      `VideoUrl` varchar(200) DEFAULT NULL,
      `FileUrl` varchar(200) DEFAULT NULL,
      `Content` longtext,
      `Summary` longtext,
      `Author` varchar(255) DEFAULT NULL,
      `Source` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`Id`),
      KEY `IX_model_Content` (`IsTop`,`Taxis`,`Id`),
      KEY `IX_model_Content_Taxis` (`Taxis`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1
    
  2. starlying commented on Jun 12, 2018

    @starlying
    Contributor

    对,mysql默认不支持中文

  3. russellyi commented on Jun 12, 2018

    @russellyi
    Author

    我看了下,只有内容表 model_content 是这样latin1,其他表默认都是utf8。

  4. starlying commented on Jun 12, 2018

    @starlying
    Contributor

    是有问题,系统创建内容表的时候没有加上utf8,我们会修复一下

  5. starlying commented on Jul 1, 2018

    @starlying
    Contributor

    已修复

  6. russellyi commented on Jul 27, 2018

    @russellyi
    Author

    这个问题还是存在。是否需要将utf8修改为utf8mb4

    Incorrect string value: '\xF0\x9F\x98\x83' for column 'Title' at row 1
    
    在 MySql.Data.MySqlClient.MySqlStream.ReadPacket() 在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) 在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) 在 MySql.Data.MySqlClient.MySqlDataReader.NextResult() 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() 在 SiteServer.CMS.Data.DbHelper.ExecuteNonQuery(IDbCommand command) 在 SiteServer.CMS.Data.DbHelper.ExecuteNonQuery(IDbConnection connection, String commandText, IDataParameter[] commandParameters) 在 SiteServer.CMS.Data.DbHelper.ExecuteNonQuery(String connectionString, String commandText, IDataParameter[] commandParameters) 在 SiteServer.CMS.Provider.ContentDao.Update(String tableName, IContentInfo contentInfo) 在 SiteServer.CMS.Provider.ContentDao.Update(String tableName, SiteInfo siteInfo, IContentInfo contentInfo) 在 SiteServer.BackgroundPages.Cms.PageContentAdd.Submit_OnClick(Object sender, EventArgs e)
    
    2018-07-27 17:12:16
    
  7. starlying commented on Jul 30, 2018

    @starlying
    Contributor

    感觉不像是utf8导致的

  8. russellyi commented on Jul 30, 2018

    @russellyi
    Author

    现在数据库是不是不支持存储表情 😃(= \xF0\x9F\x98\x83)? 上面那个问题就是在内容标题上加了表情才出现的。

  9. starlying commented on Jul 30, 2018

    @starlying
    Contributor

    哦,那应该就是这个导致的,我们会把utf8改成utf8mb4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions