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 make column nullable
  • how to fill null values in sql
  • sql - How to select data from MySQL table where a column is NULL
  • sql blank vs null
  • how to check if a column is null in sql
  • which columns has null data?
  • C# datareadeer return null
  • set value to null sql
  • sql from null to not null
  • sql if null then string
  • make parameters nullable in sql server
  • get null data in sql
  • change sql column from null to not null
  • update set table column to null
  • sql is null
  • sql is null
  • ms sql check if column is nullable
  • make column not null in jpa
  • SQL IS NULL
  • how to find columns with null values in sql
  • get null value in sql
  • Select from SQL table if the value is NULL
  • how to select null values in sql

  • 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.