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 6134339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:20:34+00:00 2026-05-23T17:20:34+00:00

I am using SQL Server 2008 in a asp.net/c# program. I am trying to

  • 0

I am using SQL Server 2008 in a asp.net/c# program. I am trying to use SqlDataReader to fetch the data form the db, but I’m not sure what to use for the datatype “bit”.

//these are the assemblies i added manually
using System.Web.Script.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ucsConnectionString"].ConnectionString);
SqlDataReader rdr2 = null;
conn2.Open();

SqlCommand cmder = new SqlCommand("usp_Device_GetBy_DeviceID", conn2);
cmder.Parameters.AddWithValue("@ID", id);
cmder.CommandType = CommandType.StoredProcedure;
rdr2 = cmder.ExecuteReader();
rdr2.Read();

*insert datatype & var* = rdr2.GetSqlBit(rdr2.GetOrdinal("Line_Name"));

I found a couple sites that referenced the above “GetSqlBit” but apparently it is not part of the assemblies I’m using. Any suggestions how I can read this “bit” datatype from SQL?

I found a similar datatype using “GetSqlBinary” but I don’t fully understand how it works or if it would be appropriate for this situation?

Everyone’s ongoing help is appreciated!

  • 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-23T17:20:34+00:00Added an answer on May 23, 2026 at 5:20 pm

    A bit stored in a database can actually have three states, not just two: 0, 1, and NULL. For this reason, the type you want is a Nullable<bool>, or the bool? shorthand.

    However, it looks like you want the .GetBoolean() method. That method requires you to check for null before calling the method. The code might look like this:

    bool? Line_Name = rdr2.IsDBNull(rdr2.GetOrdinal("Line_Name"))?null:rdr2.GetBoolean(rdr2.GetOrdinal("Line_Name"));
    if (Line_Name != null && Line_Name.Value)
    {
        //...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net web application written in C# using a SQL Server 2008
I'm developing an ASP.NET app (C#) that connect to SQL Server 2008 using ADO.NET
I am developing a asp.net application and i am using SQL Server 2008. I
I'm developing ASP.NET 4.0 Website using SQL server 2008 with Membership Framework. It runs
I'm using SQL Server 2008 and I would like to use a sproc to
I am looking for a ASP.NET 4 and MS SQL Server 2008 hosting. I
Is it possible to connect to a SQL Server Express 2008 database in ASP.NET
I am using SQL Server 2008 Enterprise + VSTS 2008 + C# + .Net
I am using SQL Server 2008 Enterprise. And using ADO.Net + C# + .Net
I am using SQL Server 2008 Enterprise. And using ADO.Net + C# + .Net

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.