Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Clear content of table in a MDB

Posted on 2009-02-17
Medium Priority
Last Modified: 2012-05-06

Im trying to delete the data in a table in MDB , I call the data into a dataset then clear the dataset and save changes ....... this does not seam to work

Any ideas ?
Question by:MichMat
  • 3
  • 2
LVL 48

Expert Comment

ID: 23665529
You don't need to do that. You just have to create a connection to the database and execute a OledbCommand to clear all the information with a T-SQL like "DELETE * FROM myTable"
 Here you have an example of the OledbCommand

Author Comment

ID: 23665667
I cant seam to get this code to work it throws up no errors and it does nothing
its the same code that saves to the file shouldnt that work the same way ?
 Sub DeleteMeetingsData()
        Dim oCommT As OleDbCommand
        Dim oDataT As OleDbDataAdapter
        Dim ConnectT, oMainQueryT As String
        Dim OleConnT As OleDbConnection
            ConnectT = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AppPath & "\Import.mdb;User ID=Admin;Password="
            oMainQueryT = "DELETE * FROM Meetings"
            OleConnT = New OleDbConnection(ConnectT)
            oCommT = New OleDbCommand(oMainQueryT, OleConnT)
            oDataT = New OleDbDataAdapter(oMainQueryT, OleConnT)
            Dim cbT As OleDbCommandBuilder = New OleDbCommandBuilder(oDataT)
    End Sub

Open in new window

LVL 48

Accepted Solution

jpaulino earned 2000 total points
ID: 23665712
You don't need to use OleDbDataAdapter or OleDbCommandBuilder.
This should be enough

    Using connection As New OleDbConnection(ConnectT)
        Dim command As New OleDbCommand(oMainQueryT, connection)
    End Using

Open in new window


Author Closing Comment

ID: 31548069
Yes, you are right :) that works perfectly. Thank you so much for your help.
LVL 48

Expert Comment

ID: 23668619
Glad I could help

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question