命名通过vb.net编码的新访问表

时间:2019-04-08 08:53:18

标签: vb.net ms-access

嘿,我一直在查看有关在vb.net中命名已创建表的文章,尽管我使用的是相同的代码,但显然我的语法不适用于使用文本框中的名称创建新表。你thinK是什么?

 dbprovider = "Provider=Microsoft.ACE.OLEDB.12.0;"
        dbsource = "Data Source = FULL YUGIOH ACCESS DATABASE.accdb;"
        conn.ConnectionString = dbprovider & dbsource
        Dim connectionString As String = dbprovider & dbsource
        Using con As New OleDbConnection(connectionString)
            con.Open()
            Using cmd As New OleDbCommand()
                cmd.Connection = con
                cmd.CommandText = "CREATE TABLE " & TextBox4.Text & "(ID COUNTER, [name] STRING)"
                Try
                    cmd.ExecuteNonQuery()
                    MsgBox("Table created.")
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            End Using
            con.Close()
        End Using
    End Sub

0 个答案:

没有答案