User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 403,519 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,807 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1033 | Replies: 5 | Solved
Reply
Join Date: Aug 2007
Posts: 7
Reputation: SPereira is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SPereira SPereira is offline Offline
Newbie Poster

Connection.Execute command to Delete Records from MS Access Database Table

  #1  
Jul 16th, 2008
Hi Guys,

I have written a program in VB 6 wherein I want to delete a particular record from MS Access Database Table. I noticed that the record does not get deleted immediately. Only after I close the recordset it disappears. I have a Delete Command Button in a Form that deletes a particular record. After deletion, when I browse the records in the table I noticed that the record has not been deleted. It is only when I close the Form which closes the recordset to that table and when I reopen the recordset I notice that the record gets deleted then. My code is as follows.

Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"

where Conn is set to a New Connection. So what I did was close the recordset and then reopen it again soon after the above command is executed as follows.

Rs.Close
Rs.Open "SELECT * FROM <tablename> ORDER BY FIELD1", Conn, , , cmdTable

Please let me know if I am doing this the right way or is there any other method of solving this issue? But I want to use the Connection.Execute command only.

Please help. Thanks.
SPereira
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 78
Reputation: manoshailu is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 6
manoshailu's Avatar
manoshailu manoshailu is offline Offline
Junior Poster in Training

Re: Connection.Execute command to Delete Records from MS Access Database Table

  #2  
Jul 16th, 2008
HI,

To Refresh the Recordset you can use the ReQuery which the query executes again to get the proper results.


Shailaja


Originally Posted by SPereira View Post
Hi Guys,

I have written a program in VB 6 wherein I want to delete a particular record from MS Access Database Table. I noticed that the record does not get deleted immediately. Only after I close the recordset it disappears. I have a Delete Command Button in a Form that deletes a particular record. After deletion, when I browse the records in the table I noticed that the record has not been deleted. It is only when I close the Form which closes the recordset to that table and when I reopen the recordset I notice that the record gets deleted then. My code is as follows.

Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"

where Conn is set to a New Connection. So what I did was close the recordset and then reopen it again soon after the above command is executed as follows.

Rs.Close
Rs.Open "SELECT * FROM <tablename> ORDER BY FIELD1", Conn, , , cmdTable

Please let me know if I am doing this the right way or is there any other method of solving this issue? But I want to use the Connection.Execute command only.

Please help. Thanks.
SPereira
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: Connection.Execute command to Delete Records from MS Access Database Table

  #3  
Jul 16th, 2008
try to use this
  1. conn.begintrans
  2. Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"
  3. conn.committrans
Share your Knowledge.
Reply With Quote  
Join Date: Aug 2007
Posts: 7
Reputation: SPereira is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SPereira SPereira is offline Offline
Newbie Poster

Re: Connection.Execute command to Delete Records from MS Access Database Table

  #4  
Jul 17th, 2008
Hi Shailaja,

Thanks alot. The ReQuery option did the trick. Now I can move on with ease.

C Ya.


Originally Posted by manoshailu View Post
HI,

To Refresh the Recordset you can use the ReQuery which the query executes again to get the proper results.


Shailaja
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: vishvaabala is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vishvaabala vishvaabala is offline Offline
Newbie Poster

Re: Connection.Execute command to Delete Records from MS Access Database Table

  #5  
Jul 19th, 2008
HI

Give the Follwing Cmds

Con.Begintrans
Con.execute "Delete From Table Where Cond..."
Con.Commitrans
Reply With Quote  
Join Date: Aug 2007
Posts: 7
Reputation: SPereira is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
SPereira SPereira is offline Offline
Newbie Poster

Re: Connection.Execute command to Delete Records from MS Access Database Table

  #6  
Jul 19th, 2008
Hi

I did try the begintrans / committrans but it somehow didn't work out. But the Requery option did work.

Thanks anyway.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 1:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC