声明结束预期,初学者

时间:2013-08-25 10:13:38

标签: asp.net sql vb.net

请帮我解决。我还是初学者

Imports System.Data
Imports System.Data.SqlClient

Partial Class MBranches
    Inherits System.Web.UI.Page

    Dim connString As String = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        If Page.IsValid Then
            Dim conn As New SqlConnection(connString)
            conn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|APU.mdf;Integrated Security=true; User Instance=true"
            conn.Open()
                Dim SqlString As String = "INSERT INTO tblBranch (BranchName, BranchAddress, BranchContactNumber) VALUES ("& txtName.Text &","& txtAddress.Text &","& txtCNumber.Text")"
            conn.Close()
        End If
    End Sub
End Class

1 个答案:

答案 0 :(得分:1)

这是一个简单的语法错误,Visual Studio应该清楚地指出。你错过了&符号&在你的SqlString中。

你应该为自己找到这个......但它就在最后一行。