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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:13:00+00:00 2026-05-28T13:13:00+00:00

So I have a tab delimited file that I need to insert through sqlbulkinsert.

  • 0

So I have a tab delimited file that I need to insert through sqlbulkinsert. I have all my code written and working properly, but when I reach a value that is assigned an integer or decimal without a value inputted, my code breaks because the assignment is incorrect (a null to a decimal value)… How can I handle this?

dataRow["variableName"] = splitString[IndexValue]; // decimal coming in blank because this column doesn't have a decimal assigned (and not required)

Thanks!

Edit: I do know I can test the value for null before assignment, but would prefer not using an if check if there’s another way to cast this.

Ended up using the ternary operator.

dataRow["variableName"] = (String.IsNullOrEmpty(splitString[IndexValue])) ? Convert.ToInt32(splitString) : 0;
  • 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-28T13:13:00+00:00Added an answer on May 28, 2026 at 1:13 pm

    Do a simple check before the assignment:

    if (varT != null)
     //perform assignment
    else
    

    Change varT to the name of the value you are checking against.
    Also you need to tell us what is null and what isn’t it is hard to tell with the content of your question. Is splitString[IndexValue] null or the datarow?

    Per your comment you can make use of the conditional operator:

    return varT != null ? varT : 1.0;

    Or as others have mentioned you can use the ?? operator http://msdn.microsoft.com/en-us/library/ms173224.aspx

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

Sidebar

Related Questions

I have a tab delimited text file that I need to upload to a
I have a tab-delimited file that has over 200 million lines. What's the fastest
I have a tab delimited file on a shared path. I've setup that flat
I have a text file that is tab delimited and looks like: 1_0 NP_045689
Almost every project that I work will have some sort of tab delimited file
I have a tab-delimited text file that I am parsing. Its first column contains
I have a tab delimited file that contains date, header row, some values, empty
Let's say I have a tab-delimited text file that contains data arranged in columns
I have a file that is tab delimited. I would like a powershell script
I have a php script that steps through a folder containing tab delimited files,

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.