查询表达式SN ='中的语法错误缺少运算符。在vb6中 [英] Syntax error missing operator in query expression SN='. In vb6

查看:95
本文介绍了查询表达式SN ='中的语法错误缺少运算符。在vb6中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Delete_Click()
   
    
    con.Open Constr 
    rs.Open "Select Name,Phoneno,Age from Test where  SN  =" & addEdit.Text, con           
    For a = 1 To ListView1.ListItems.Count 
        If ListView1.ListItems.Item(a).Checked = True Then 
            addEdit.Text = rs("SN")
                
            sql = "delete from Test where SN=" & addEdit.Text
            addEdit.Text = "SN"
            NameText.Text = ""
            PhText.Text = ""
            AgeText.Text = ""
            NameText.SetFocus
            con.Execute (sql)
        End If
        rs.MoveNext
    Next
    con.Close
   
End Sub





我尝试了什么:



尝试: - Id = SN显示在edittext框中



What I have tried:

try to :- Id=SN is show in edittext box

推荐答案

你没有提到哪一行引发错误。我猜这一行是个问题。代码缺失=

You didn't mention which line is throwing the error. I'm guessing this line is the issue. The code is missing "="
rs.Open "Select  Name,Phoneno,Age from Test where  SN " & addEdit.Text, con, adOpenStatic, adLockReadOnly





应该是



it should be

rs.Open "Select  Name,Phoneno,Age from Test where  SN = " & addEdit.Text, con, adOpenStatic, adLockReadOnly


问题来自于包含 addEdit 我们无法知道。

-----

您的代码受SQL注入攻击

SQL注入 [ ^ ]

-----

当你不明白你的代码在做什么或为什么它做它做的时候,答案是调试器

使用调试器查看代码正在执行的操作。它允许你逐行执行第1行并在执行时检查变量,它是一个令人难以置信的学习工具。



调试器 - 维基百科,免费的百科全书 [ ^ ]



调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。

调试器中没有魔法,它没有找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。
The problem comes from the contain of addEdit that we can't know.
-----
You code is subject to SQL injection attack
SQL Injection[^]
-----
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. It allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于查询表达式SN ='中的语法错误缺少运算符。在vb6中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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