Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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


What I have tried:

try to :- Id=SN is show in edittext box
Posted
Updated 2-Feb-17 19:10pm
v8

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


it should be
VB
rs.Open "Select  Name,Phoneno,Age from Test where  SN = " & addEdit.Text, con, adOpenStatic, adLockReadOnly
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900