I have an application that contains a textbox wherein my database could only accept an int value, which is the contact number. The contact number field is only optional, so an empty field couldn't be accepted because it's still a character and not a number. How could I fix this? Need help.
AngelicOne
4
Posting Whiz
Recommended Answers
Jump to Postint? contactNumber = null; if (myTextBox.Text != String.Empty) { contactNumber = Int32.Parse(myTextBox.Text); } // contactNumber is now either null or contains the number or an Exception was thrown because Parse was unable to convert what was entered.
Jump to PostYou may also like to read this: http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=VS.80).aspx
All 8 Replies
Momerath
1,327
Nearly a Senior Poster
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
Mitja Bonca
557
Nearly a Posting Maven
AngelicOne
4
Posting Whiz
Mitja Bonca
557
Nearly a Posting Maven
AngelicOne
4
Posting Whiz
AngelicOne
4
Posting Whiz
Mitja Bonca
557
Nearly a Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.