473,491 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DELETE Query Functions in Access but not in VB.NET

4 New Member
I have a very frustrating and confusing problem here; I have a SQL query that functions perfectly well in Access however when I code it in VB.NET it does not yield the desired results;here is the code:

Expand|Select|Wrap|Line Numbers
  1.         Dim oledbConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & InstallLocation & "SDE.mdb;User Id=admin;Password=;")
  2.         oledbConnection.Open()
  3.  
  4.         Dim oledbCommand As New OleDb.OleDbCommand("DELETE Sheet1.F4 FROM Sheet1 WHERE (((Sheet1.F4) Is Null)) OR (Sheet1.F4) LIKE '*E*';", oledbConnection)
  5.         oledbCommand.ExecuteNonQuery()
  6.         oledbConnection.Close()
The query runs and all nulls are dropped from the table, however none of rows that contain "E" get dropped.

Any advice would be greatly appreciated.
Aug 26 '07 #1
5 2150
gponto18
4 New Member
To narrow down the problem a bit, this line executes but does not delete anything from the table, even though when run in Access, it works fine:

Expand|Select|Wrap|Line Numbers
  1. DELETE Sheet1.F4 FROM Sheet1 WHERE (Sheet1.F4) LIKE '*E*';
Aug 26 '07 #2
kenobewan
4,871 Recognized Expert Specialist
I suggest removing the ";", not used to access in sql we use %. However does seem like a syntax problem.
Aug 26 '07 #3
gponto18
4 New Member
I suggest removing the ";", not used to access in sql we use %. However does seem like a syntax problem.
Thank you for your reply; I tried your suggestion, unfortunately removing the ";" has no appreciable effect.

What is particularly vexing about this problem is that the statement works perfectly in Access but not in VB.NET.
Aug 26 '07 #4
gponto18
4 New Member
Well I was able to solve this problem by using the Access Interop Libraries and running the SQL Query internally in Access.

Somehow though I think there must be a better way to do this.
Aug 26 '07 #5
thaboloko
2 New Member
if you want to execute your query by using the oledbcommand (that would improve your app performance, I guess...) you should replace the star sign ( * ) with a percent sign ( % ) on your LIKE Operator.

That should solve the problem, I figure it out that , after several days.

Check your code again here, I made the correction:

Dim oledbConnection As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=" & InstallLocation & "SDE.mdb;User Id=admin;Password=;")
oledbConnection.Open()

Dim oledbCommand As New OleDb.OleDbCommand("DELETE Sheet1.F4 FROM Sheet1 WHERE (((Sheet1.F4) Is Null)) OR (Sheet1.F4) LIKE '%E%';", oledbConnection)
oledbCommand.ExecuteNonQuery()
oledbConnection.Close()

PS. Remove the ";" anyway. =]
Aug 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2313
by: Clive | last post by:
Hello everyone, This is my first time posting, up until now i've only used google to seach :) I'm creating a multiplayer minesweeper game in Windows, so I have been reading up on CSockets. I...
2
2557
by: Dave Burt | last post by:
Hi, Access officionados, I'm new here, so please cut me slack/gently tell me off if I'm out of line or in the wrong place. OK, here's something that seems silly (and is also problematic to...
7
5877
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
8
25023
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a...
10
3304
by: nick_faye | last post by:
Hi guys, i'm still a newbie in using MS Access and in VB programming. I am using DAO connection from my VB to access the entries on my MS Access table. I am having trouble in editting and...
3
3422
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
13
2824
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
3
3792
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
10
2027
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.