How to validate/save date in Asp.Net using VB.NET? -
this question has answer here:
- date saving in sql using vb.net 2 answers
this code meant save date
if(not string.isnullorempty(datetxt.text)) sqlcmd.parameters.add("@dte",sqldbtype.date)=datetxt.text.trim() end if
what must add code validation too?
check answer here,
dim datevalue date if string.isnullorwhitespace(dobtxt.text) sqlcmd.parameters.add("@dob", sqldbtype.date).value = dbnull.value elseif date.tryparse(dobtxt.text.trim(), datevalue) sqlcmd.parameters.add("@dob", sqldbtype.date).value = datevalue else ' alert user there invalid input end if
Comments
Post a Comment