【问题标题】:Save in mysql line that is in greek letter C#保存在希腊字母 C# 中的 mysql 行中
【发布时间】:2014-06-20 02:29:18
【问题描述】:

数据库中的希腊字符就像问号(“?????”)。我找不到解决方案。当我在 MySQL 中插入希腊字母时,就像问号一样。 mysql中talbe中的Tha排序规则是utf8。

我做错了什么?

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {


            int col = this.dataGridView1.CurrentCell.ColumnIndex;
            int row = this.dataGridView1.CurrentCell.RowIndex;




         if (e.ColumnIndex == dataGridView1.Columns["priceoneDataGridViewTextBoxColumn"].Index)
                  {
                     string name =  dataGridView1.Rows[row].Cells[col - 1].Value.ToString();

                        string pric= dataGridView1.Rows[row].Cells[col].Value.ToString();

//in this row i am getting the line ok
                     MessageBox.Show(name); 


                      MessageBox.Show(pric);

                      lawyerspriceDataSet ds = new lawyerspriceDataSet();
                      lawyerspriceDataSetTableAdapters.reportTableAdapter daReport = new lawyerspriceDataSetTableAdapters.reportTableAdapter();
                      daReport.Fill(ds.report);
                      try
                      {
                          daReport.Insert(name, pric); //i save the info in the table


                      }

                      catch (Exception ex)
                      {
                          MessageBox.Show("error");
                      }


           }
   ![enter image description here][1]

【问题讨论】:

  • 这里描述了您的问题的解决方案:stackoverflow.com/questions/1385994/…
  • 我无法在我的代码中找到放置 charset=utf8 的位置
  • 您应该将其添加到连接字符串中。它可能位于您的 winforms 应用程序的 app.config 文件中。
  • server=kosh-PC;User Id=root;database=lawyersprice;Persist Security Info=True;Character Set=utf8 。我成功了,但还是不行
  • 你试过 CharSet=utf8 吗?

标签: c# mysql datagridview grammar


【解决方案1】:

这个答案帮助我修复它link

我进入我的“nameofapp”设置并输入字符串 charset=utf8 ,然后我进入我的数据库表并将排序规则放入 utf8_bin 并开始工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 2017-07-22
    相关资源
    最近更新 更多