•
•
•
•
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 456,567 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,595 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: 1105 | Replies: 2 | Solved
![]() |
| |
•
•
Join Date: Aug 2006
Posts: 20
Reputation:
Rep Power: 3
Solved Threads: 1
' Here is the code -- beware I am deleting all Rows.. Please add condition to the query
' I would also advise you to modify the logic in future, to retain the row and flag the row as delete
Sub Delete_Rows()
Dim Cn As ADODB.Connection '* Connection String
Dim oCM As ADODB.Command '* Command Object
Dim sQuery As String '* Query String
Dim lRow
On Error GoTo ADO_ERROR
Set Cn = New ADODB.Connection
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\160831\My Documents\db4.mdb';Persist Security Info=False"
Cn.ConnectionTimeout = 40
Cn.Open
Set oCM = New ADODB.Command
oCM.ActiveConnection = Cn
oCM.CommandText = "Delete From Sample"
oCM.Execute lRow
MsgBox "Deleted " & lRow & " rows"
Application.StatusBar = False
If Not oCM Is Nothing Then Set oCM = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing
ADO_ERROR:
If Err <> 0 Then
Debug.Assert Err = 0
MsgBox Err.Description
Resume Next
End If
End Sub
' I would also advise you to modify the logic in future, to retain the row and flag the row as delete
Sub Delete_Rows()
Dim Cn As ADODB.Connection '* Connection String
Dim oCM As ADODB.Command '* Command Object
Dim sQuery As String '* Query String
Dim lRow
On Error GoTo ADO_ERROR
Set Cn = New ADODB.Connection
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\160831\My Documents\db4.mdb';Persist Security Info=False"
Cn.ConnectionTimeout = 40
Cn.Open
Set oCM = New ADODB.Command
oCM.ActiveConnection = Cn
oCM.CommandText = "Delete From Sample"
oCM.Execute lRow
MsgBox "Deleted " & lRow & " rows"
Application.StatusBar = False
If Not oCM Is Nothing Then Set oCM = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing
ADO_ERROR:
If Err <> 0 Then
Debug.Assert Err = 0
MsgBox Err.Description
Resume Next
End If
End Sub
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation api avatar backup blogger blogging blogs breach code combo dani daniweb data data protection database debugging design development dreamweaver dropdownlist gdata google government gpl hacker ibm key linux medicine microsoft module news normalization openbsd product programming reuse rss security serial server source sql survey tags vista web wysiwyg xml
- retrieving current record in database (Visual Basic 4 / 5 / 6)
- Beginner: how to add new record into database??? (VB.NET)
- updating a database (ASP.NET)
- Criminal Record Database (Computer Science and Software Design)
- [Please HELP] Cannot Update Record (PHP)
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- link record in database with contactItem? (Visual Basic 4 / 5 / 6)
- Deleting a record from a file (C)
- how willl i be able to save a specific record into my database file in ms access (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to use SQL in VB
- Next Thread: The operaor Or


Hybrid Mode