Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ques about string.empty

Status
Not open for further replies.

purplehaze1

Programmer
Jul 23, 2003
86
US
How do you write the same for integer variable (eg. m_itemid)?
i.e. if m_itemID is not filled by user, while saving the record, I want to leave it blank on database table.
Thankyou.


Dim dr as dararow

dr("item_desc") = IIf(m_itemDesc = String.Empty, string.empty, m_itemDesc)
dr("item_id") = ??
 
nothing perhaps?



Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Code:
dr("item_id") = IIf (m_ItemID = 0, DBNull.Value, m_ItemID)

-Kris
 
You can't store a DBNull in the integer itself, so you either need to use a separate boolean flag (If IsItemChanged Then), or use a special value within the range of an integer to indicate the same condition (If m_ItemID = Integer.MinValue Then).

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
What do you mean by

You can't store a DBNull in the integer itself

The code which I have posted will work without any problem. If you are setting a DBNull.Value to an Integer Variable, you will get an error, but in this case it is setting the value directly to the datarow, and that will work without any error. I do this all the time.

-Kris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top