Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 28, 2012 12:24 PM by GmGregori
Participant
896 Points
238 Posts
Apr 28, 2012 08:19 AM|LINK
What value u want to save,,
i think it is mobile no ??
if it is mobile no then string is also comfortable for it..
Member
9 Points
40 Posts
Apr 28, 2012 10:12 AM|LINK
Dear Mahesh..
my problem is when client leave textbox empty then how to insert emptytextbox value into integer field column.
Still i m waiting for ur reply..
546 Points
98 Posts
Apr 28, 2012 10:16 AM|LINK
You can have a convention in this case, e.g. you can insert either 0 or -1 if the entry is empty and thn when you wanna retrive it if it was 0 or -1 it means no entry.
Contributor
5460 Points
737 Posts
Apr 28, 2012 12:24 PM|LINK
Another possible solution is to employ two distinct insert queries, one with the null value and the other with the input value:
if(IsPost) { if(string.IsNullOrEmpty(Request["val"])){ db.Execute("INSERT INTO Nullable(nullint) VALUES(NULL)"); } else { db.Execute("INSERT INTO Nullable(nullint) VALUES(@0)", Convert.ToInt32(Request["val"])); } }
It isn't good-looking, but it works.
Mahesh Darku...
Participant
896 Points
238 Posts
Re: Conversion of Empty Textbox into int field of database table
Apr 28, 2012 08:19 AM|LINK
What value u want to save,,
i think it is mobile no ??
if it is mobile no then string is also comfortable for it..
zeeshanfazal
Member
9 Points
40 Posts
Re: Conversion of Empty Textbox into int field of database table
Apr 28, 2012 10:12 AM|LINK
Dear Mahesh..
my problem is when client leave textbox empty then how to insert emptytextbox value into integer field column.
Still i m waiting for ur reply..
Amin.Mirzapo...
Member
546 Points
98 Posts
Re: Conversion of Empty Textbox into int field of database table
Apr 28, 2012 10:16 AM|LINK
You can have a convention in this case, e.g. you can insert either 0 or -1 if the entry is empty and thn when you wanna retrive it if it was 0 or -1 it means no entry.
GmGregori
Contributor
5460 Points
737 Posts
Re: Conversion of Empty Textbox into int field of database table
Apr 28, 2012 12:24 PM|LINK
Another possible solution is to employ two distinct insert queries, one with the null value and the other with the input value:
if(IsPost) { if(string.IsNullOrEmpty(Request["val"])){ db.Execute("INSERT INTO Nullable(nullint) VALUES(NULL)"); } else { db.Execute("INSERT INTO Nullable(nullint) VALUES(@0)", Convert.ToInt32(Request["val"])); } }It isn't good-looking, but it works.