使用插入到语句时出现问题 [英] Problem Using Insert Into Statement

查看:102
本文介绍了使用插入到语句时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

兄弟
使用插入到语句时出现严重问题.

我用两个文本框制作了一个小程序
1. txtName
2. txtRollNo.
当我在这些字段中输入任何数据时,程序运行正常.
但是,当我在任何字段中输入逗号()时,都会出现以下错误.

Brothers
I am having a critical problem in using Insert Into Statement.

I made a small program with Two Textboxes
1. txtName
2. txtRollNo.
When I Enter any data in these fields, the Programs runs fine.
But when I Entered a Comma ( '' ) in any field it gives me the following Error.

Syntax Error in string in query Expression "144");''.


(注意:我在RollNo文本框中输入144和一个逗号().)

我在程序中使用了以下Insert Into语句


(Note: I entered 144 and a comma ( '' ) in the RollNo text box.)

I used the following Insert Into Statement in my program

"Insert into tblStudent(Name,RollNo) Values(''" & txtName.Text & "'',''" & txtRollNo.Text & "'');"



请帮助我解决此问题.



Plz Help me In solving this problem.

推荐答案

尽管建议使用参数化查询并绑定到准备好的语句或使用存储过程,但也可以替换单引号"""使用""表示,因为""被翻译回单个".请查看下面的链接以获取更多信息.

http://it.toolbox.com/wiki/index.php/How_do_I_escape_single_quotes_in_SQL_queries%3F [a> [ ^ ]

祝你好运!
Although advisable to use parametrized queries and bind to the prepared statement or use stored procedures, you could also replace the single quote "''" by "''''" because "''''" is translated back into a single "''". Have a look at the link below for more info.

http://it.toolbox.com/wiki/index.php/How_do_I_escape_single_quotes_in_SQL_queries%3F[^]

Good luck!


感谢所有兄弟.
使用替换功能"时,我的问题已解决.
感谢所有兄弟.
Thanks to all brothers.
When I used Replace Function my problem was solved.
Thanks to all Brothers.


这篇关于使用插入到语句时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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