Search code examples
vb.netvisual-studio-2010ms-access-2007oledb

How to select Yes/No field in MS Access (I get an error)


Right now I have this code:

 Dim adapter As New OleDbDataAdapter("Select 1stShift as [First Shift] from &_ 
 EmployeeDesignation where EmployeeID= '" & empID & "' and &_
 DesignationDate= '" & day & "'", DBConnection)

I get an error "Syntax error (missing operator) in query expression '1stShift'."

But if I change 1stShift to EmployeeID, or DesignationDate, which are both "Text" fields, it works just fine.

Please enlighten me. Thank you!


Solution

  • assuming 1stShift is a valid column name this should work

     Dim adapter As New OleDbDataAdapter("Select [1stShift] as [First Shift] from " &_ 
     "EmployeeDesignation where EmployeeID= '" & empID & "' and "&_
     "DesignationDate= '" & day & "'", DBConnection)