CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Location
    Québec (Canada)
    Posts
    210

    Delete table in Access Database

    How can I delete table in Access Database?

    I try with this:

    Dim dbsNew As Database
    Dim wrkDefault As Workspace
    Dim td As TableDef
    Set dbsNew = OpenConnection("c:\Windows\Temp\MarteleurVirtuel.mdb")

    Set wrkDefault = DBEngine.Workspaces(0)
    td.Name = "Position ha"
    dbsNew.TableDefs.Delete td

    But it was not a success. I recive an error at the last line: ("Type mismatch")


    Has anyone can help me?
    Thanks!

    Redg


  2. #2
    Join Date
    Jul 1999
    Location
    Sandhem, Sweden
    Posts
    35

    Re: Delete table in Access Database

    Hi.

    When you're going to delete a table you don't need to declare a TableDef object.

    Do like this:
    dbsNew.TableDefs.Delete "Position ha"



    /Michael Nattfalk


  3. #3
    Join Date
    Nov 1999
    Location
    Denver, CO
    Posts
    20

    Re: Delete table in Access Database

    Redg,

    Try this code instead and change the what you need to change.

    Dim dbsNew As Database
    Dim td As TableDef

    Set dbsNew = OpenDatabase("d:\vbhelp\tbldel\db3.mdb")
    dbsNew.TableDefs.Delete "Table1"


    Allen Noakes
    VB Programmer/Analyst
    Dames & Moore Group
    [email protected]


  4. #4
    Join Date
    Aug 1999
    Location
    India-Delhi
    Posts
    106

    Re: Delete table in Access Database

    Hi,
    use the following.

    dim codegurudb as database
    dim mysql as string
    set codegurudb = workspaces(0).opendatabase(app.path & "\test.mdb")
    'say table name is xxx
    mysql = "DROP TABLE xxx"
    codegurudb.execute mysql
    codegurudb.close



    I assume that in project reference you add the DAO.


    Santulan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured