Retrieving a bit column from sql database in VB NET

前端 未结 4 1814
闹比i
闹比i 2021-01-22 22:03

I have encountered a problem where in my database I have a column that is a bit either 0 or 1 specifying if a user is an admin or is account suspended or not. And in my VB code

4条回答
  •  -上瘾入骨i
    2021-01-22 22:39

    You want

      newrow.Item("SESSuspended") = rdr.GetBoolean(2)
      newrow.Item("SESAdmin") = rdr.GetBoolean(3)
    

    You should also change these lines

      dtRequests.Columns.Add("SESSuspended", System.Type.GetType("System.Byte"))
      dtRequests.Columns.Add("SESAdmin", System.Type.GetType("System.Byte"))
    

    to

    dtRequests.Columns.Add("SESSuspended", System.Type.GetType("System.Boolean"))
    dtRequests.Columns.Add("SESAdmin", System.Type.GetType("System.Boolean"))
    

提交回复
热议问题