Click to See Complete Forum and Search --> : ADO


Kathy
August 18th, 1999, 10:14 AM
Hi,

I want to overwrite a table MyTable. I tried:

cmd.CommandText = "Drop Table MyTable"
--> All it does is delete all the data, but the table is still there

Then I try create MyTable again
cmd.CammandText = "Create MyTable col1 char(10) "
----> ERROR MyTable already exist ????

askus
August 19th, 1999, 04:31 AM
We tried the following code in VB and having sqlserver 7.0 as backend , its working perfectly.
Public MyConn As ADODB.Connection

Set MyConn = New ADODB.Connection

ConnStr = "Provider=sqloledb;Driver={SQL Server};Server=" & <Your ServerName> & ";Initial Catalog=" & <Your Database Name> & ";User ID=sa;password=;"

MyConn.ConnectionString = ConnStr

Dim cmd As New ADODB.Command

Set cmd.ActiveConnection = MyConn
cmd.CommandText = "Drop table MyTable"
cmd.Execute

cmd.CommandText = "create table MyTable(MyCol varchar(10))"
cmd.Execute

The Ultimate Solution Providers

Authors

Sriman & Jayaraman

Email : solutionproviders@hotmail.com
solutionproviders@yahoo.com

Hand Phone : +(6) 016 2237147 (Malaysia)