The problem is when i delete a records from the listview, it deleted but when i look unto database it doesn't deleted.
Please help me solve this problem:

Here's my recent code:


        Dim sqlconn As New OleDb.OleDbConnection
        Dim Button = MessageBox.Show _
        ("Are you sure you want to delete this Data?", _
        "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
        If Not ListView1.SelectedItems.Count = 0 Then
            If Button = Windows.Forms.DialogResult.Yes Then
                Dim sqlcmd As New OleDb.OleDbCommand("DELETE FROM table1 WHERE Processor="", Memory="", VideoCard="", HardDrive="", AntiVirus="" ", sqlconn)
                MsgBox("Record Removed Successfully~!", MsgBoxStyle.Critical)
                MsgBox("No Record Selected.", MsgBoxStyle.Critical)
            End If
            MsgBox("No Record Selected.", MsgBoxStyle.Critical)
        End If
3 Years
Discussion Span
Last Post by sonyeo

DELETE FROM table1 WHERE Processor="", Memory="", VideoCard="", HardDrive="", AntiVirus="" "

Shouldn't there be AMD betweem variables instead of commas?

DELETE FROM table1 WHERE Processor="" AND Memory="" AND VideoCard="" AND HardDrive="" AND AntiVirus=""

Another possibility: use Nothing instead of ""

DELETE FROM table1 WHERE Processor=Nothing AND Memory=Nothing AND VideoCard=Nothing AND HardDrive=Nothing AND AntiVirus=Nothing

Which of the above (if any) is correct will depend on the contents of the database.


Hey bro, thanks for the response.. but..
i think the problem in my program is not connecting into the database...
it just deleting the records that listed in the listview but its not affecting my database..
please help me solve this^^


Huh? I didn't say anything about connecting to the database. What I mentioned is the SQL statement required to delete a row from the database after the connection has been made.

You need to get the values of the columns from the listview row you want to delete and plug them into the SQL statement which is probably why the sql statement doesn't work.

Edited by Ancient Dragon


the SQL statement is correct,. but the connecting to the database is something wrong.
could you give me a code to connect to my database.~? my database is SERVICE-BASED DATABASE...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.