Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

SQL Data Reader - handling Null column values

Narshe answered on March 22, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • SQL Alter column to be not null
  • which columns has null data?
  • sql select except null
  • datatable columns with nullable fields ajax
  • sql if null then 0
  • include null values in json sql server
  • sql select column with value NULL
  • sql blank vs null
  • sql - How to select data from MySQL table where a column is NULL
  • sql make column nullable
  • how to fill null values in sql
  • how to check if a column is null in sql
  • which columns has null data?
  • sql from null to not null
  • C# datareadeer return null
  • set value to null sql
  • make parameters nullable in sql server
  • sql if null then string
  • get null data in sql
  • change sql column from null to not null
  • sql is null
  • update set table column to null
  • sql is null
  • ms sql check if column is nullable
  • how to find columns with null values in sql
  • SQL IS NULL
  • get null value in sql
  • Select from SQL table if the value is NULL
  • how to select null values in sql
  • Is there a way to use read_sql_query and the query has WHERE column = Variable?

  • SQL Data Reader - handling Null column values

    0

    For nullable types (i.e. strings)

    employee.FirstName = sqlreader[indexFirstName] as string;


    For primitive values (i.e. integer), if you cast to a nullable int, you can use GetValueOrDefault()

    employee.Age = (sqlreader[indexAge] as int?).GetValueOrDefault();


    or the null-coalescing operator (??).

    employee.Age = (sqlreader[indexAge] as int?) ?? 0; 

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Link to this answer
    Share Copy Link
    Contributed on Mar 22 2023
    Narshe
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.