Avatar of Starr Duskk
Starr DuskkFlag for United States of America asked on

Handling System.DBNull.Value

When I'm working with an ID field on my page, I want to have it saved as -1 if it's not ever been defined as a valid ID. But when I go to save the values to the table, if they're -1, I want to save them as System.DBNull.Value.

How can I create a function to return the valid value as an integer if it's not -1, but if it is -1, to return System.DBNull.Value, so that it saves properly to the table?


Avatar of undefined
Last Comment
Starr Duskk

8/22/2022 - Mon

Does the column in your database allow null value?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Starr Duskk

I had requested this for deletion before your answer was posted here. but I don't mind giving you the points since they're all paid for anyway. but I had found another solution.

thanks for the reply! Maybe it will come in handy on another project.

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck