佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1572|回复: 9

MySQL ODBC 3.51 Driver 不能用来insert 中文字to mysql?

[复制链接]
发表于 17-7-2007 03:54 PM | 显示全部楼层 |阅读模式
Dim ConnStr As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
                "SERVER=localhost;" & _
                "DATABASE=db_member;" & _
                "UID=tester;" & _
                "PASSWORD=12345;" & _
                "OPTION=3;" & _
                "CHARSET=utf8;"

以上是我用在asp.net web application的connection string..
我不能正常insert中文字to mysql.. 和显示中文字from mysql..为何呢?
回复

使用道具 举报


ADVERTISEMENT

发表于 17-7-2007 03:59 PM | 显示全部楼层

回复 #1 counterking 的帖子

cannot insert chinese character into table ?
I can insert chinese character into table.
不能DISPLAY ON THE SCREEN, 但RETRIEVE,你会看到..
set the Collation of the field = utf8_bin

[ 本帖最后由 thkee 于 17-7-2007 04:06 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 18-7-2007 02:53 PM | 显示全部楼层
注意! 如果是在local 做testing.. 是一切都没问题。。 但如果deploy on server就出现这样的问题

我已经改了。。 但还是不能显示中文字。。。。



[ 本帖最后由 counterking 于 18-7-2007 02:55 PM 编辑 ]
回复

使用道具 举报

发表于 18-7-2007 03:00 PM | 显示全部楼层

回复 #3 counterking 的帖子

不是。
I set on the structur of the field ...
例子:table A has a field call msg ....
then the Collation of the field = utf8_bin
回复

使用道具 举报

发表于 18-7-2007 03:10 PM | 显示全部楼层

回复 #3 counterking 的帖子

Ur server can support UTF8 ?
回复

使用道具 举报

 楼主| 发表于 18-7-2007 10:51 PM | 显示全部楼层
可以阿。。。 我问过hosting company乐
回复

使用道具 举报

Follow Us
 楼主| 发表于 19-7-2007 08:15 PM | 显示全部楼层
我已经试过把 structure of field 换去 utf8_bin OR UTF8 都是不能....why??  testing in my local pc everything is okie.. once deploy in webser就出问题了
回复

使用道具 举报

 楼主| 发表于 20-7-2007 04:47 PM | 显示全部楼层
我的问题是... 无论是input or output chinese words from mysql database..
都会变成???的乱码...然而这个问题只在我deploy去web server才出现,
testing run in my local pc是可以input and output chinese words to mysql database

以下是我最新的更动... 我使用的mysql version = 4.1.22

我在每一个page放了这段meta tag
<meta http-equiv="Content-Type" ccolor: Red; font-weight: bold;">charset=UTF-8" />
-------------------------------------------------------------------------------
MySql的field structure也设定为
collation = utf8_bin
-----------------------------------------------------------------------------------------------
                MySQL connection collation: = utf8_unicode_ci
-------------------------------------------------------------------------------
然后connection string 也设定为

Dim ConnStr As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
                "SERVER=localhost;" & _
                "DATABASE=db_member;" & _
                "UID=tester;" & _
                "PASSWORD=12345;" & _
                "OPTION=3;" & _
               
"CHARSET=utf8;"
----------------------------------------------------------------------------------------------
    Dim MyConn As New OdbcConnection(ConnStr)
    Dim Str As String
    Dim cmd As New OdbcCommand(Str, MyConn)

  Str = "INSERT INTO user_table (name, address) VALUES ('我的名字', '我的地址')"

        cmd.CommandText = Str

        Try
            MyConn.Open()
            Added = cmd.ExecuteNonQuery()
            success = True
        Catch ex As Exception
            success = False
            MessageBox(ex.Message)
        Finally
            If Not MyConn Is Nothing Then
                MyConn.Close()
            End If
        End Try

回复

使用道具 举报


ADVERTISEMENT

发表于 25-7-2007 01:20 PM | 显示全部楼层
Try to set the mysql

mysqld --charachter_set_server=gbk
or
mysqld-nt --character_set_server=gbk
回复

使用道具 举报

小嘴唇 该用户已被删除
发表于 25-7-2007 01:33 PM | 显示全部楼层

回复 #8 counterking 的帖子

Table 的 Collation set to = latin1_general_ci

还有 make sure webserver there is the same setting

是不是 at here the value had encode to other and not the UTF-8 anymore?
Str = "INSERT INTO user_table (name, address) VALUES ('我的名字', '我的地址')"
是不是 要encode before insert into db ?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 29-9-2025 06:15 AM , Processed in 0.136044 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表