General discussion

Locked

Delete all records

By mus301295 ·
How do I delete ALL records in Access using Adodc?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Delete all records

by Miss Kitty In reply to Delete all records

Hi. I set up a delete query in my Access database and then run the query to delete all the records, but not the table.

Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objRS As New ADODB.Recordset
Dim objParam As ADODB.Parameter
Dim count As Integer

'set up the database pointer
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=E:\ACCESS\CONTRACT HAULERS\HAULER.mdb;User ID=ADMIN"
objRS.CursorType = adOpenDynamic
objRS.LockType = adLockOptimistic

'setting the Active Connection for the command object
objCmd.ActiveConnection = objConn

'Providing the query name as commandtext
objCmd.CommandText = "[DELETE TTICKET QUERY]"
objCmd.CommandType = adCmdStoredProc

'Set the recordset to the command object result
Set objRS = objCmd.Execute
This works real good. I need to keep the table as a work table and by doing it this way I emptyit before I run a new query.
Good Luck.
Cathy
covcat@riverstonegrp.com

Collapse -

Delete all records

by mus301295 In reply to Delete all records

The question was auto-closed by TechRepublic

Collapse -

Delete all records

by Mohammad_M_Saggaf In reply to Delete all records

Hi,
The answer 1 correct but I have an easier answer.

Dim Conn As New ADODB.Connection

'set up the database pointer
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\test.mdb;User ID=ADMIN"

'executethe deletion sql statement.
' This code line does all the work.
Conn.Execute "Delete * from table1"

'Close the connection
Conn.Close

' Free the resources
Set Conn = nothing

I hope I helped

Collapse -

Delete all records

by mus301295 In reply to Delete all records

The question was auto-closed by TechRepublic

Collapse -

Delete all records

by mus301295 In reply to Delete all records

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums