PDA

View Full Version : how i can delete a table in a database in vb programing? thanks!


tshm
07-03-02, 22:39
i'm attempting to delete a table in a database when i program using vb how can i get it?

rnealejr
07-04-02, 00:58
Are you trying to delete the actual table or just all the records in the table ? Which database are you using ?

Rasatan
07-28-02, 23:21
_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...

Sef
09-10-02, 10:39
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