Link to home
Start Free TrialLog in
Avatar of rbichon
rbichon

asked on

OleDbCommand DELETE WHERE LIKE

I am writing a vb.Net subroutine that is supposed to delete records from a database if the field "File" partially matches something. Here is my code:


                sql = "DELETE * FROM `Call Log` WHERE File LIKE '*test.wav' AND Protect = False"
                cstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=c:\test.mdb;Jet OLEDB:Database Password=pass123;"
                Dim conn As OleDbConnection = New OleDbConnection(cstring)
                conn.Open()
                Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
                If (cmd.ExecuteNonQuery() = 1) Then
                    'Perform other things
                End If
                conn.Close()

The problem is that this code isn't working. Please help.
Avatar of YZlat
YZlat
Flag of United States of America image

try running your query in Access
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbichon
rbichon

ASKER

That was it. I was using the '*' instead of the '%' for the wildcard. Thanks for the simple correction.