Mysql命令出错。 [英] Error in Mysql Command.

查看:53
本文介绍了Mysql命令出错。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用撇号这样的单词时,它会在mysql命令中生成''s'错误检查你的手册。

因为我们使用''& texbox .text&''在mysql命令中。因此,当我们输入类似这样的东西时,它输入为''它'''并产生错误,所以任何解决方案。等待........



更好理解。



whenever i use a word with apostrophe like it''s , it generate''s " a error in mysql command check your manual ".
because as we use ''"& texbox.text &"'' in mysql commmand . so as we type something like this it input as ''its''s'' and generate error , so any solution . Waiting ........

for Better Understanding.

Dim cn As New MySqlConnection
    Dim cd As MySqlCommand
    Dim s As String

cn.ConnectionString = "server=localhost; user id=root; password=; database=dc"
            cn.Open()
s = " insert into table_name(column1,column2,..column_n) values('"& textbox1.text&"')"
            cd = New MySqlCommand(s, cn)
            cd.ExecuteNonQuery()
            cn.Close()

推荐答案

可以您提供导致此错误的代码。您已经提到过使用asp.net 4的标签。使用框架实现这种行为真的很难。



一般来说,建议使用预准备语句来执行查询。

例如,如果使用SQLCommand - 代码可以是


Can you provide a code that causes this error. You have mentioned using tag that asp.net 4 is used. It is really hard to achieve such behavior using framework.

Generally speaking, it is recommended to use prepared statements to execute the query.
For example, if SQLCommand is used - the code could be

command->CommandText = S"insert into Region (RegionID, RegionDescription) values (@id, @desc)" ;
command->Parameters->Add (S"@id", __box(id));
command->Parameters->Add (S"@desc", desc);
command->Prepare();  // Calling Prepare after having set the CommandText and parameters.
command->ExecuteNonQuery();









http://msdn.microsoft.com/en-us/library/system。 data.sqlclient.sqlcommand.prepare(v = vs.71).aspx [ ^ ]


这篇关于Mysql命令出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆