|
-
Apr 30th, 2004, 06:14 PM
#1
Thread Starter
Junior Member
Delete all records in Jet data base from vb6 program
I need to delete all records in the Security table that relate to the investor umber. This is the code I used in my vb6 application.
When I run this I get a dialog box which says "Operation is not allowed when object is closed."
Even though this message appears, the table's records do delete.
adoDelete.RecordSource = "DELETE FROM Security Where Investor_Number = " & txtInvestorNumber
adoDelete.Refresh
Any ideas on why this dialog shows or what I need to keep it from being displayed?
Thank you,
Dwight
-
Apr 30th, 2004, 08:42 PM
#2
Are you using the ADO Data control?
Where is your connection code? The recordset needs an open
connection to execute the SQL code.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 1st, 2004, 06:54 PM
#3
Thread Starter
Junior Member
Property Page Dialog box
Hey RobDog,
I set the connection string of the ado using the property
pages dialog box(right clicking the ado object).
Then a change the recordsource through code, as required, as I listed above.
My feeling is that even though calling the record source in this manner seems to work fine when adding, appending or deleting a single record, I must have to do it another way to delete multiple records using the "delete" method.
Please help me with this if you can.
I am new to vb6 and sql.
Thanks so much,
Dwight
-
May 2nd, 2004, 06:19 AM
#4
Junior Member
Try binding the ado control to a label on design, even if it won't show anything.
-
May 3rd, 2004, 06:23 AM
#5
Thread Starter
Junior Member
Did not work
Hi geraf,
Thanks for the effort, but it did not work.
Any more suggestions?
The idea was great, but binding the ado to a label did prevent the error message from appearing.
As before though the table data relating to the filter(investor number) did delete.
My only problem here is figuring out why the errror and what I need to do to correct it.
Regards,
Dwight
-
May 3rd, 2004, 11:13 AM
#6
Instead of trying to pass the delete sql use the control's .Delete
method and apply a filter for the delete criteria.
VB Code:
Private Sub Command1_Click()
Adodc1.Recordset.Filter = "Investor_Number = '" & txtInvestorNumber & "'"
Adodc1.Recordset.Delete adAffectGroup
Adodc1.Recordset.UpdateBatch adAffectGroup
Adodc1.Recordset.Filter = adFilterNone
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|