Asp.net send null value to database
Remove From My Forums. Answered by:. Archived Forums. Getting Started with ASP. NET question on a topic that's not covered by one of the other more specific forums - ask it here. Sign in to vote. I have two dropdowns 2nd one is dependent on 1st one. So 2nd dropdown has a foriengn key in database. But 2nd dropdown is not compulsory.
Here is my code. Text; c. Checked; c. Parse ddlDistrict. SelectedValue ; c. Parse ddlLocal. ToInt32 DBNull. Value : int. Can anyone help me please. What does an empty form field equal? You need to use DBNull. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 10 years, 11 months ago. Active 5 years, 7 months ago. Viewed 91k times. Here is the required part of the code, if you require more just let me know. StoredProcedure cmdInsert. NVarChar firstname. Input firstname. Write "NULL" address1. Value Else Response. Improve this question. Jammer Jammer 2, 11 11 gold badges 45 45 silver badges 73 73 bronze badges. Add a comment. Active Oldest Votes.
Value If String. Text End If. DateTime ; if txtdateofexpiry. Parameters[" DateofExpiry"]. ToDateTime txtdateofexpiry. Improve this question. Add a comment. Active Oldest Votes. DateTime is not a nullable type. If you don't supply a value it's equal to DateTime. MinValue You can use DateTime? MyNullableDateTime; This question has more detail in the answer, if you are interested.
Improve this answer. Community Bot 1 1 1 silver badge. Neil Thompson Neil Thompson 6, 2 2 gold badges 28 28 silver badges 51 51 bronze badges. Simple here you can give DbNull. Value to pass NULL value. Sreekumar P Sreekumar P 5, 10 10 gold badges 56 56 silver badges 80 80 bronze badges. Here's an example: DateTime? TryParseExact txtdateofexpiry.
0コメント