Solved

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

Posted on 2004-10-02
2
130 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
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

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