Is this a bug?

  • Thread starter Thread starter Nick
  • Start date Start date
Hi all,
I'm running a sql statement to delete records in a table in Access database.
If I run it inside the Access, it deletes with no problem, but when I call it
from vb.net(oledb), it doesn't delete any records and I don't get any errors.
Here's the code:
cmd.CommandText = DELETE FROM TABBLE WHERE FIELD1 LIKE 'A*'
cmd.ExecuteNonQuery()
Am I missing something here? Thanks for your input.
Roy
 
Hi Roy,

If I remember correctly, Access uses "*" and "?" as wilcards, while ODBC
drivers, OLEDB Provides, etc. uses ANSI "%" and "_" wildcards respectively.

So, try:

cmd.CommandText = DELETE FROM TABBLE WHERE FIELD1 LIKE 'A%'

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Sorry Roy I was just being stupid.

Try replacing the * with % and see if that works.

Nick
 
Roy said:
If I run it inside the Access, it deletes with no problem, but when I
call it from vb.net(oledb), it doesn't delete any records and I don't
get any errors.
DELETE FROM TABBLE WHERE FIELD1 LIKE 'A*'

You don't get an error because this statement is successfully deleting
zero rows. There aren't any rows in in TABBLE where FIELD1
contains the value "Ayy asterisk".
The wildcard character for OLEDB is "%", not "*". Try

DELETE FROM TABBLE WHERE FIELD1 LIKE 'A%'

instead.

HTH,
Phill W.
 
I just remembered after I saw your replies- that is a sign I'm getting old
for this
Thank you all,
 
Try,

DELETE * FROM TABBLE WHERE FIELD1 LIKE 'A%'


| I just remembered after I saw your replies- that is a sign I'm getting old
| for this
| Thank you all,
|
| "Phill. W" wrote:
|
| > | > > If I run it inside the Access, it deletes with no problem, but when I
| > > call it from vb.net(oledb), it doesn't delete any records and I don't
| > > get any errors.
| >
| > > DELETE FROM TABBLE WHERE FIELD1 LIKE 'A*'
| >
| > You don't get an error because this statement is successfully deleting
| > zero rows. There aren't any rows in in TABBLE where FIELD1
| > contains the value "Ayy asterisk".
| > The wildcard character for OLEDB is "%", not "*". Try
| >
| > DELETE FROM TABBLE WHERE FIELD1 LIKE 'A%'
| >
| > instead.
| >
| > HTH,
| > Phill W.
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top