0

I'm having trouble getting a SQL 2008 R2 Express table to drop using VB. Here is my code:

Private Sub Form10_AssyWIP_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    Dim sqConQC As New SqlClient.SqlConnection("Server=QCG11\SQLEXPRESS;Database=QCGMAIN; Trusted_Connection=True;")
    Dim sqCmdQC As New SqlClient.SqlCommand

    sqCmdQC.Connection = sqConQC            'create the DB connection 
    sqConQC.Open()                        'open the connection
    Dim ds As New DataSet
    Dim Adapter As New SqlDataAdapter
    Dim pivot As String
    Dim sql As String
    Dim drop As String
    'Read the data

    drop = "DROP TABLE AssyWIP"
    Adapter.SelectCommand = New SqlCommand(drop, sqConQC)
    sqConQC.Close()
    End Sub
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Fedaykin
  • 25
  • 1
  • 6

1 Answers1

1

I'd use a SqlCommand for this:

    drop = "DROP TABLE AssyWIP"
    Dim command As New SqlCommand(drop, sqConQC)
    command.ExecuteNonQuery()
    sqConQC.Close()
sgeddes
  • 62,311
  • 6
  • 61
  • 83
  • Okay, now I just feel silly! Thank you very much. I was cutting and pasting some griddataview fill code and trying to make it run commands against the SQL with an Adapter. – Fedaykin May 02 '13 at 00:15