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

x
?
Solved

Clear content of table in a MDB

Posted on 2009-02-17
5
Medium Priority
?
171 Views
Last Modified: 2012-05-06
Hi

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 ?
0
Comment
Question by:MichMat
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:jpaulino
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
http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbcommand.executenonquery.aspx 
0
 

Author Comment

by:MichMat
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)
            OleConnT.Close()
    End Sub

Open in new window

0
 
LVL 48

Accepted Solution

by:
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)
        connection.Open()
        Dim command As New OleDbCommand(oMainQueryT, connection)
        command.ExecuteNonQuery()
    End Using

Open in new window

0
 

Author Closing Comment

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

Expert Comment

by:jpaulino
ID: 23668619
Glad I could help
jpaulino
0

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