0

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

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
4

1 回答 1

1

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

你应该自己找到这个..但它在行尾。

于 2013-08-25T10:19:45.673 回答