Solved

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

Posted on 2004-10-02
2
128 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 50 total points
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to trouble shoot .net contact form 3 30
DataGridView 2 28
Visual Studio installation 5 32
VB.Net - For Loop Error 5 23
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

12 Experts available now in Live!

Get 1:1 Help Now