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 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
Reply
Join Date: Jul 2007
Posts: 102
Reputation: hawisme000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
hawisme000's Avatar
hawisme000 hawisme000 is offline Offline
Junior Poster

Question Code for Deleting a Record in a database??

  #1  
Oct 23rd, 2007
elow, can any1 tell me whats the code for deleting a record in a database??

or deleting a row?

my table is consist of fields..

lecID
arlNumber
arlLec
arlPart

thx in advance to,
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2006
Posts: 20
Reputation: shasur is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
shasur shasur is offline Offline
Newbie Poster

Re: Code for Deleting a Record in a database??

  #2  
Oct 23rd, 2007
' 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
Reply With Quote  
Join Date: Jul 2007
Posts: 102
Reputation: hawisme000 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
hawisme000's Avatar
hawisme000 hawisme000 is offline Offline
Junior Poster

Re: Code for Deleting a Record in a database??

  #3  
Oct 23rd, 2007
Ty sir ive solve my prob about this


thx!!!
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 5:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC