|
-
May 3rd, 2005, 10:34 AM
#1
Thread Starter
Junior Member
Error: String was not recognized as a valid DateTime
Hi,
I have an asp.net web application,
I retrieve a stored session value from first page in 2nd page:
Dim AppFromDate1 As Object
If Session("FromDate1") Is DBNull.Value Then
AppFromDate1 = String.Empty
Else
AppFromDate1 = (Session("FromDate1"))
End If
When it's null string "", the run time value is ""{String}.
For inserting to the database, I set the parameter value as:
dbDetail.Parameters.Add(New SqlParameter("@AppFromDate1", SqlDbType.DateTime))
and I manage the value as :
Dim sqldatenull As SqlDateTime
sqldatenull = SqlDateTime.Null
If (AppFromDate1 = "") Then
dbDetail.Parameters("@AppFromDate1").Value = sqldatenull
Else
dbDetail.Parameters("@AppFromDate1").Value = DateTime.Parse(AppFromDate1)
End If
HOWEVER, dbDetail.Parameters("@AppFromDate1").Value = sqldatenull doesn't work, it still put the value to ""{string}, and the insert failed for an error:
"String was not recognized as a valid DateTime".
Please help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|