VB 6 Select语句问题,其中单个字符串下的字符串中包含单个字符串 [英] VB 6 Select Statement problem with single cote within a string under single cote

查看:135
本文介绍了VB 6 Select语句问题,其中单个字符串下的字符串中包含单个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VB6中使用具有ms访问权限的Data对象
错误消息:运行时错误3075
代码:
设置db = OpenDatabase(App.Path&"\ db.mdb")

昏暗的snrs作为记录集
设置snrs = db.OpenRecordset(从[entry]中选择*,其中[NAME] ="&Me.txtname.Text和"")

从[输入]中选择*,其中[NAME] =''"&Me.txtname.Text&''"

现在,当Me.txtname.Text
上没有Single Cote时,它的工作正常
例如,如果名称是a.b或a.c cba,除了ab's或bc's以外,实际上采石场正变得像

从[输入]中选择*,其中[NAME] =''"&bc's&''"

从[输入]中选择*,其中[NAME] =``bc''s''":现在,这将导致错误

他们的解决方案是什么,请给我建议

Hi i am using Data object in VB6 with ms access
error massage : run-time error 3075
code :
Set db = OpenDatabase(App.Path & "\db.mdb")

Dim snrs As Recordset
Set snrs = db.OpenRecordset("select * from [entry] where [NAME]= ''" & Me.txtname.Text & "''")

"select * from [entry] where [NAME]= ''" & Me.txtname.Text & "''"

now its working fine when no Single cote on Me.txtname.Text

for example if the name is a.b or a.c cba what ever except like ab''s or bc''s actually the quarry is becoming like

"select * from [entry] where [NAME]= ''" & bc''s & "''"

"select * from [entry] where [NAME]= ''bc''s''" : now this is causing an error

is their any solution for this please suggest me alternatives

推荐答案

使用参数,因为请阅读以下内容

数据库-为什么我应该使用参数而不是将值放入我的SQL字符串中? [
Use parameters because read the below one

Database - Why should I use Parameters instead of putting values into my SQL string?[^]


这篇关于VB 6 Select语句问题,其中单个字符串下的字符串中包含单个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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