我在连接我的sql中的2列时出现问题。有人可以检查我的联合声明中出了什么问题。
查询:
Public Function getStudents(ByVal oStudentsBO As StudentsBO) As DataTable
dt = New DataTable
sql = "SELECT [KY_ID_NUM] as [ID Num], [NM_NICK] as [Nick Name], [CD_AGE_GROUP] as [Age Group], " &
"[NM_LAST] as [Last Name], [NM_FIRST] as [First Name], " &
"CONCAT(NM_GFIRST, NM_GLAST) FROM [tblStudents] " &
"WHERE [NM_FIRST] Like '%" & oStudentsBO.NM_FIRST & "%'" &
"OR [NM_NICK] LIKE '%" & oStudentsBO.NM_NICK & "%'" &
"OR [NM_LAST] Like '%" & oStudentsBO.NM_LAST & "%'"
dt = oDA.getDataTable(sql)
Return dt
End Function
错误:
答案 0 :(得分:0)
MS Access没有CONCAT功能。相反,您必须使用字符串连接:
Public Function getStudents(ByVal oStudentsBO As StudentsBO) As DataTable
dt = New DataTable
sql = "SELECT [KY_ID_NUM] as [ID Num], [NM_NICK] as [Nick Name], [CD_AGE_GROUP] as [Age Group], " &
"[NM_LAST] as [Last Name], [NM_FIRST] as [First Name], " &
" [NM_GFIRST] & [NM_GLAST] FROM [tblStudents] " &
"WHERE [NM_FIRST] Like '%" & oStudentsBO.NM_FIRST & "%'" &
"OR [NM_NICK] LIKE '%" & oStudentsBO.NM_NICK & "%'" &
"OR [NM_LAST] Like '%" & oStudentsBO.NM_LAST & "%'"
dt = oDA.getDataTable(sql)
Return dt
End Function