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.OL EDB.4.0;Da ta 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.
sql = "DELETE * FROM `Call Log` WHERE File LIKE '*test.wav' AND Protect = False"
cstring = "Provider=Microsoft.JET.OL
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.
try running your query in Access
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it. I was using the '*' instead of the '%' for the wildcard. Thanks for the simple correction.