在 table 名称(用户)附近收到语法错误
Receiving Syntax error near the table name (User)
我收到这个错误
Incorrect syntax error near "table name"
这是我的代码的一部分
Using con As New SqlClient.SqlConnection("Server=xxx.xxx.x.x,1433;Database=XX;User ID=xxxxx;Password=xxxxxxxxx")
con.Open()
Dim cmd As New SqlCommand("SELECT * FROM User WHERE Username=@user AND Password=@pass", con)
cmd.Parameters.AddWithValue("@user", TextBox1.Text)
cmd.Parameters.AddWithValue("@pass", TextBox2.Text)
cmd.ExecuteNonQuery()
Dim adap As New SqlDataAdapter(cmd)
Dim tab As New DataTable
adap.Fill(tab)
End Using
我正在使用 SQL Server 2022
User
是关键字,如果用括号[User]
怎么办?
Dim cmd As New SqlCommand("SELECT * FROM [User] WHERE Username=@user AND Password=@pass", con)
我收到这个错误
Incorrect syntax error near "table name"
这是我的代码的一部分
Using con As New SqlClient.SqlConnection("Server=xxx.xxx.x.x,1433;Database=XX;User ID=xxxxx;Password=xxxxxxxxx")
con.Open()
Dim cmd As New SqlCommand("SELECT * FROM User WHERE Username=@user AND Password=@pass", con)
cmd.Parameters.AddWithValue("@user", TextBox1.Text)
cmd.Parameters.AddWithValue("@pass", TextBox2.Text)
cmd.ExecuteNonQuery()
Dim adap As New SqlDataAdapter(cmd)
Dim tab As New DataTable
adap.Fill(tab)
End Using
我正在使用 SQL Server 2022
User
是关键字,如果用括号[User]
怎么办?
Dim cmd As New SqlCommand("SELECT * FROM [User] WHERE Username=@user AND Password=@pass", con)