现在我有这样的代码:
Dim adapter As New OleDbDataAdapter("Select 1stShift as [First Shift] from &_
EmployeeDesignation where EmployeeID= '" & empID & "' and &_
DesignationDate= '" & day & "'", DBConnection)
我得到一个错误"语法错误(缺少操作符)在查询表达式'1stShift'."
但是如果我将1stShift更改为EmployeeID或DesignationDate,这两个都是"文本"字段,它工作得很好。
请开导我。谢谢你!
尝试将1stShift
放入方括号中:
"Select [1stShift] . . . "
许多数据库不允许常规标识符以数字开头。如果是,那么它期望在可能产生错误的数字(某种类型)后面有一个操作符。
假设1stShift是一个有效的列名,这应该可以工作
Dim adapter As New OleDbDataAdapter("Select [1stShift] as [First Shift] from " &_
"EmployeeDesignation where EmployeeID= '" & empID & "' and "&_
"DesignationDate= '" & day & "'", DBConnection)