Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do you delete a table in an access table in Vb.net

Posted on 2004-10-02
2
Medium Priority
?
138 Views
Last Modified: 2010-04-23
I am using the following code already ,is the solution along these lines?

  Public Function IsTableInExistance(ByVal TableName As String) As Boolean
        Try
            conn.Open()
            Dim schemaTable As DataTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
                                New Object() {Nothing, Nothing, Nothing, "TABLE"})
            TableName = TableName.ToUpper
            For Each row As DataRow In schemaTable.Rows
                Dim TblName As String = row(2)
                If TblName.ToUpper = TableName Then
                    Return True
                End If
            Next

        Catch Ex As Exception
            Throw New System.Exception("An exception has occurred. " & Ex.Message)
        Finally
            conn.Close()
        End Try
    End Function
0
Comment
Question by:visualbasic
2 Comments
 
LVL 3

Accepted Solution

by:
Arundel_Castle earned 200 total points
ID: 12207003
You don't need to do all that. Just issue a "Drop Table" SQL statment against the table you want removed. You can find the syntax for the drop statement in access help. Try it out first in the Query builder first. If you have records in there remember to delete them out first (if you are using relations between tables, otherwise you will get an error message about breaking the referential integrity) Use a "Delete * " SQL statment. If you have no parameters to pass place both statements as queries in access. You can then execute both of them with a OLEDB Command object. If you don't know what table it is your going to delete then use a prameter in both statements. This way you won't have to cycle throught the list of tables in your database. If the table doesn't exist you can also capture the error like you have above.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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 …
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 …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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