Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    4

    Unanswered: how i can delete a table in a database in vb programing? thanks!

    i'm attempting to delete a table in a database when i program using vb how can i get it?

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Are you trying to delete the actual table or just all the records in the table ? Which database are you using ?

  3. #3
    Join Date
    Jul 2002
    Location
    Veracruz, Mexico
    Posts
    6

    Thumbs up You can delete a table doing this:

    _Use this to DROP a table

    Dim conectar As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim fld As ADODB.Field
    Dim sql As String
    Set conectar = New ADODB.Connection
    conectar.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" _
    & "SERVER=192.168.0.1;" _
    & "DATABASE=<database>;" _
    & "UID=<whatever_user>;PWD=<password>;OPTION=35"
    conectar.Open

    You can use directly--------->>>>>>>>>>>
    rs.execute "DROP TABLE IF EXIST <table_name>"
    -----Or you can use dinamic-----

    sql ="DROP TABLE IF EXIST" & <table_name by a textbox or msgbox or whatever>& "
    rs.execute sql
    --------------------------

    I hope that this help you...

  4. #4
    Join Date
    Aug 2002
    Location
    Kampala, Uganda - East Africa
    Posts
    13

    Wink

    Hy,
    I am assuming that you want to DELETE a table in an access database.


    Dim Dbs AS Database
    Set Dbs = OpenDatabase(App.Path & "\dbname.mdb")
    Dbs.EXECUTE "DROP TABLE tabname"
    Dbs.Close

    1. App.Path will search for the location of the database on your PC
    2. Replace dbname with the name of the actual database from which you wish to delete a table.
    3. tabname is the name of the table to be deleted.

    In case you just want to delete all records, replace line 3 with;
    Dbs.EXECUTE "DELETE * FROM tabname"


    Nice time.

    Sef

Posting Permissions

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