Drop A Table

Discussion in 'Questions (Windows Mobile)' started by ceaser, Nov 19, 2008.

  1. ceaser

    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
     
  2. Cableguy

    Cableguy Expert Licensed User

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

    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Main.Job is a variable or the actual name?
    The single quotes should wrap the complete name, however this query should work without quotes as well.
    You can try to first write the complete statement without any variables.
     
  5. 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
     
  6. Cableguy

    Cableguy Expert Licensed 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?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice