473,473 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

delete records in adodb record set

86 New Member
Hi all, i am using ms access 2003,

i have a form,
i connect to the mysql database using adodb connection.
this works fine.

but when i delete a record, it is deleted but still the record set shows that record.
when i close the application and again run it, then the record set dosnt show the delted record.

what could be the problem


my code goes like this
rsInfotable is a adodb record set

i opened the record set with the code
Expand|Select|Wrap|Line Numbers
  1.  str = "select * from infotable;"
  2. rsInfotable.Open str, objConn, adOpenKeyset, adLockOptimistic
  3.  

Expand|Select|Wrap|Line Numbers
  1.  
  2. If txtAutonumber.Visible Then
  3.  
  4.  
  5.  
  6.             rsInfotable.Delete
  7.  
  8.  
  9.             MsgBox ("Record has been successfully Deleted")
  10.             rsInfotable.MoveNext
  11.  
  12.  
  13.         If rsInfotable.EOF And rsInfotable.BOF Then
  14.             MsgBox ("No more records")
  15.             Call DiableButtons
  16.             Exit Sub
  17.  
  18.         ElseIf rsInfotable.EOF Then
  19.             rsInfotable.MoveLast
  20.              Call DisplayData
  21.  
  22.  
  23.         End If
  24.     End If
  25.  

though i do it with rsInfotable.delete it still shows the record in the record set
Feb 25 '09 #1
7 5737
MikeTheBike
639 Recognized Expert Contributor
Hi

I am not sure how this deleted record shows its self in the procedure (ie. what is the problem?), but just perhaps you could change this

If rsInfotable.EOF And rsInfotable.BOF Then

to this

If rsInfotable.RecordCount = 0 Then

????


MTB
Feb 25 '09 #2
ravindarjobs
86 New Member
my application target is very simple that
1. connect to the database
2. add records,
3. edit records,
4. navigate through records
5. and delete records.

i am doing all these fine except that deleting record.

when i delete with my code, the records are deleted in the database, but the record set still contains that record.

suppose say, i have 20 records, and now i am at say 8th record, now i pressed delete button and i perform a movenext action. The record is deleted in database, but when i press previous button or like that, i am still able to see that record in my recordset. I.e i am able to navigate through the deleted record which is wrong.


do i need to requery the record set?
if i requery the recordset, then the current position will be lost which is not a correct approach.

what is happening with my code?

thank you
Feb 25 '09 #3
MikeTheBike
639 Recognized Expert Contributor
Hi again

Well, I cannot fine any think wrong with your code (except for to suggestion in my last post as an error occures when there are not records left!). Other than that I cannot see where this is a problem for you (ie where does this error/probelm occure?). Perhaps I am missing something simple.

Just one thought, deleted records do remain in a FORM until it is Requeried?


MTB
Feb 25 '09 #4
ravindarjobs
86 New Member
Hi, i attached my application.

indeed there is no error coming.But functionality is wrong in my code.

have a look at the attachment.

Open the database,
1.Run the form
2. Click open connection button
3. navigate to some record, or go to final record
4. Now press delete. there comes confirmation message that record has been deleted.
5. now click previous button, or some how navigate through the records.
the deleted record still appears.

what should i do to delete from the record set



if you want to add records, click create record, enter the fields and click save button

Note:Please do not enter last field(long) while creating record. it wil not be saved, and gives error. there is some problem.


thank you
Attached Files
File Type: zip VBAAptitudeTest_JIVA Developer2.zip (51.4 KB, 133 views)
Feb 25 '09 #5
MikeTheBike
639 Recognized Expert Contributor
Hi

Unfortunately IT policy does not permit me to down load files, so I cannot look at this, but hopefully someone else will. Paticularly as I cannot simulate your problem, the deleted record just disapear when the recordset is moved.

Sorry cannot be of more help.


MTB
Feb 25 '09 #6
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi ravindarjobs. The form's code module in the example database does not compile - there is a type mismatch in the line

RecordNavigationControl6.ControlSource = rsInfotable

of your OpenConnection_Click sub. The controlsource cannot be a recordset type - it should be a tablename, query name or SQL statement of some kind. Anyway, it has nothing to do with the error being investigated.

Commenting that line out leads to another error - as we have no access to the data source that is still specified for your connection object. For test purposes you need some local data source that we can access too - such as a table within the current database.

You should make sure that any database you attach is free from errors before you attach it - encountering avoidable mistakes like this is not helpful to anyone who is spending time looking at your application...

Like MTB, I can see no obvious error in your delete routine. I wonder if you have the relevant permissions on the underlying table, however. Don't be fooled by the message saying the record is deleted - at least if what you are referring to is your own messagebox call saying the record is deleted - does not mean the system did delete the record.

I would suggest that you set up a test table within your application itself, open that table in the ADO recordset instead of the remote target, and verify as MTB has done that the code deletes a target record. If so, it is clearly a permissions issue that is preventing you from deleting the record in the remotely-connected data source.

-Stewart
Feb 25 '09 #7
NeoPa
32,556 Recognized Expert Moderator MVP
I know MTB mentioned it earlier, but I'm wondering if you caught it, as I've seen no further mention of it. After deleting a record, the recordset keeps the record holder until it is requeried.

Either requery the recordset when necessary, or recode to handle this and skip past such records where found.
Feb 25 '09 #8

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

Similar topics

0
by: karenmiddleol | last post by:
The following code works fine I can connect to a SQL database and list all the records in the Orders table onto a web page. Now our users want me to modify it so that each row displayed as a...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
0
by: Rich | last post by:
I have a page that list all records in an access table. I would like to add a delete record function to the list to delete selected records. Here is my current code: ...
10
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 ...
3
by: John Fairhurst | last post by:
Hi, The following code should select the specified number of records randomly from the database <% .... query = "SELECT FROM " Set RS = Server.CreateObject("ADODB.Recordset")
3
by: igendreau | last post by:
I'm trying to clean up a database of mine, and I need to convert some old DAO code over to ADO. When I was using DAO, I had no problem running this script and deleting the record using rs.Delete. ...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
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.