请帮我解决。我还是初学者
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
答案 0 :(得分:1)
这是一个简单的语法错误,Visual Studio应该清楚地指出。你错过了&符号&在你的SqlString中。
你应该为自己找到这个......但它就在最后一行。