VB.Net-如何从文本框

时间:2016-01-02 18:12:19

标签: vb.net ado.net oledbcommand

我正在运行此代码,没问题......

Sub CreateTable()

    Dim strCreate As String = "CREATE TABLE Info(" & _
        "CountryName varchar(120) Primary key," & _
        "Continent Integer," & _
        "Area Long," & _
        "Population Long," & _
        "Capital varchar(80)," & _
        "Code char(2));"

    Dim conDatabase As OleDbConnection = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" & _
        "Data Source= " & filepath & ";")
    Dim cmdDatabase As OleDbCommand = New OleDbCommand(strCreate, conDatabase)
    conDatabase.Open()
    cmdDatabase.ExecuteNonQuery()
    conDatabase.Close() 

但是当我通过TextBox做同样的事情时,它无法正常工作

Sub CreateTable()

    Dim strCreate As String = TextBox1.Text   'TextBox Contains Create table command

    Dim conDatabase As OleDbConnection = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" & _
        "Data Source= " & filepath & ";")
    Dim cmdDatabase As OleDbCommand = New OleDbCommand(strCreate, conDatabase)
    conDatabase.Open()

cmdDatabase.ExecuteNonQuery

conDatabase.Close()

这里有什么问题?

0 个答案:

没有答案