Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6180853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:55:08+00:00 2026-05-24T00:55:08+00:00

I have encountered a problem where in my database I have a column that

  • 0

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 I am trying to retrieve that bit. Example code:

    Dim dtRequests As DataTable
    dtRequests = New DataTable("Users")
    dtRequests.Columns.Add("SESLoginID", System.Type.GetType("System.Int32"))
    dtRequests.Columns.Add("fullname", System.Type.GetType("System.String"))
    dtRequests.Columns.Add("SESSuspended", System.Type.GetType("System.Byte"))
    dtRequests.Columns.Add("SESAdmin", System.Type.GetType("System.Byte"))
    dtRequests.Columns.Add("OfficeName", System.Type.GetType("System.String"))

    cmdoledb = New SqlCommand("SELECT SESLoginID, SESFirstName + ' ' + SESLastName As fullname , SESSuspended, SESAdmin, OfficeID from SESLogin where (SESEmail Like '%" & keyword & "%' or SESFirstName + ' ' + SESLastName like '%" & keyword & "%' or SESLastName like '%" & keyword & "%') order by SESFirstName;", objConnect)
    cmdoledb.Parameters.AddWithValue("@pid", pid)
    objConnect.Open()

    Dim rdr As SqlDataReader
    Dim myItem As ListItem = New ListItem()
    rdr = cmdoledb.ExecuteReader()

    While rdr.Read()
        Dim newrow As DataRow
        newrow = dtRequests.NewRow
        newrow.Item("SESLoginID") = rdr.GetInt32(0)
        newrow.Item("fullname") = rdr.GetString(1)
        newrow.Item("SESSuspended") = rdr.GetByte(2)  // Specified cast is not valid.
        newrow.Item("SESAdmin") = rdr.GetByte(3) // Specified cast is not valid.

        Dim officeid As Integer = rdr.GetInt32(4)
        Dim officename As String = ""

        cmdldb = New SqlCommand("SELECT OfficeName from Office where OfficeID = @offid", objConnected)
        cmdldb.Parameters.AddWithValue("@offid", officeid)
        objConnected.Open()

        officename = cmdldb.ExecuteScalar()
        newrow.Item("OfficeName") = officeid
        objConnected.Close()
        dtRequests.Rows.Add(newrow)
    End While

I tried getting rdr.GetByte(3), this tells me cast not valid, but there is no function of which will say GetBit, and if such exists I could not find it. Thus Im hoping for a quick response.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:55:09+00:00Added an answer on May 24, 2026 at 12:55 am

    Try rdr.GetBoolean(3) to get Bit values. A bit in SQL Server is the same as a boolean in VB, except it uses 1 and 0 instead of true and false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have encountered a problem that I have not come accross yet when setting
I have encountered a problem in my application. I have two forms, one that
I have encountered a most annoying problem that occurs on the PWD variable when
My problem is I have an existing table that I can not modify that
My admin folks have encountered a big problem, and I'm relaying their plight to
I have encountered a problem in importing the dump file to a new database.
I have encountered a problem twice now whereby a producer thread produces N work
I have encountered a problem of placing data into the Table View. Here is
I'm migrating a TSQL stored procedure to PL/SQL and have encountered a problem -
I am using ajaxForm. Now I have encountered a problem. My idea is when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.