我得到错误我喜欢这个“QUERY EXPRESSION中的语法错误_Name =''” 请帮帮我 。我的代码出了什么问题?
尝试
Connection.Open()
Dim query As String
query = ("SELECT * from RegistrationTable WHERE _Name = '" & ListBox1.Text & "'")
command = New OleDbCommand(query, Connection)
Reader = command.ExecuteScalar
While Reader.Read
txtPID.Text = Reader("PatientID")
txtName.Text = Reader("_Name")
txtAge.Text = Reader("_Age")
cmbGender.Text = Reader("_Gender")
End While
Connection.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
Connection.Dispose()
End Try
答案 0 :(得分:0)
该下划线表示您需要方括号:
"SELECT * from RegistrationTable WHERE [_Name] = '" & ListBox1.Text & "'"