未定义的功能' concat' vb.net

时间:2018-02-24 17:42:49

标签: vb.net ms-access concatenation

我在连接我的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

错误:

error report

1 个答案:

答案 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