Drop A Table

ceaser

Active Member
Licensed User
Hi All

I would like to Erase (Drop) a Table from a Database and I am using the following command:

cmd.CommandText="Drop Table If Exists " & Main.Job & ".HorPi"
cmd.ExecuteNonQuery

Main.Job is the name of the Database and
.HorPi is the name of the Table

But it does not work!!:(:confused::sign0148:

Please help:sign0085:

Thanks
Michael
 

Cableguy

Expert
Licensed User
Longtime User
Hi All

I would like to Erase (Drop) a Table from a Database and I am using the following command:

cmd.CommandText="Drop Table If Exists " & Main.Job & ".HorPi"
cmd.ExecuteNonQuery

Main.Job is the name of the Database and
.HorPi is the name of the Table

But it does not work!!:(:confused::sign0148:

Please help:sign0085:

Thanks
Michael

TRY THIS:
cmd.CommandText="Drop Table If Exists '" & Main.Job & "'.'HorPi'"
NOTE THE SINGLE QUOTES IN THE STATEMENTS
 

ceaser

Active Member
Licensed User
Hi Cableguy

Thanks for the help, but it does not work!:sign0148::(

Here is the complete routine:

Sub ImportDesign_Click
WaitCursor(True)
OpenDialog1.Filter = "CVS Files|*.csv"
OpenDialog1.Show
If OpenDialog1.File<>"" Then
If RadioBtn1.Checked=True Then
'Hor Pi
cmd.CommandText="Drop Table If Exists '" & Main.Job & "'.'HorPi'"
cmd.ExecuteNonQuery
Table2.LoadCSV (OpenDialog1.File, ",", True, True)
Con.CreateSQLTable ("Table2","HorPi")
End If
End If
WaitCursor(False)
Erase.Close
End Sub

Do you see anything wrong?:sign0085:

Thanks
ceaser
 

ceaser

Active Member
Licensed User
Hi Erel

Job.main is a variable. It can be any Job name that you opened, or selected to import data to that you first have to delete before importing the new data.

Regards
ceaser
 

Cableguy

Expert
Licensed User
Longtime User
For testing comands I use one litle app called sql administrator
Have a copy of you databas and use it as testground for comands...

One thing about you issue, are you sure you have thecorrect JOB connection opened?
 
Top