VB.net SQL表删除 - 表不会丢失

时间:2013-05-01 23:54:11

标签: sql vb.net sql-drop

我无法使用VB删除SQL 2008 R2 Express表。这是我的代码:

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

1 个答案:

答案 0 :(得分:1)

我会使用SqlCommand

    drop = "DROP TABLE AssyWIP"
    Dim command As New SqlCommand(drop, sqConQC)
    command.ExecuteNonQuery()
    sqConQC.Close()