Clear content of table in a MDB

Posted on 2009-02-17
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
    LVL 48

    Expert Comment

    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

    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

    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

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

    Expert Comment

    Glad I could help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now