我正在尝试使用SQL Server 2008数据库将gridview绑定到ASP.NET中的detailsview。当我尝试绑定detailsview时,收到此错误消息:
字符串未被识别为有效的DateTime。有一个未知数 单词从索引0开始。
代码:
protected void gvstudentworkshop_SelectedIndexChanged(object sender, EventArgs e)
{
this.dvuserworkshop.Visible = true;
this.dvuserworkshop.DataBind();
this.UpdatePanel1.Update();
this.Modalenroll.Show();
}
这是我正在使用的查询:
SelectCommand="
SELECT * FROM [tblUserWorkshop]
WHERE (([WorkshopName] = @WorkshopName)
AND ([WorkshopLocation] = @WorkshopLocation)
AND ([UserID] = @UserID)
AND ([WorkshopDate] = @WorkshopDate))"
UpdateCommand="
UPDATE [tblUserWorkshop]
SET [UserWorkshopPaymentStaus] = @UserWorkshopPaymentStaus,
[ReferralSource] = @ReferralSource,
[UserWorkshopState] = @UserWorkshopState,
[UserLastName] = @UserLastName,
[UserFirstname] = @UserFirstname,
[UserMiddleInitial] = @UserMiddleInitial
WHERE [WorkshopName] = @original_WorkshopName
AND [WorkshopDate] = @original_WorkshopDate
AND [WorkshopLocation] = @original_WorkshopLocation
AND [UserID] = @original_UserID
AND (([UserWorkshopPaymentStaus] = @original_UserWorkshopPaymentStaus)
OR ([UserWorkshopPaymentStaus] IS NULL
AND @original_UserWorkshopPaymentStaus IS NULL))
AND (([ReferralSource] = @original_ReferralSource)
OR ([ReferralSource] IS NULL
AND @original_ReferralSource IS NULL))
AND (([UserWorkshopState] = @original_UserWorkshopState)
OR ([UserWorkshopState] IS NULL
AND @original_UserWorkshopState IS NULL))
AND (([UserLastName] = @original_UserLastName)
OR ([UserLastName] IS NULL AND @original_UserLastName IS NULL))
AND (([UserFirstname] = @original_UserFirstname)
OR ([UserFirstname] IS NULL
AND @original_UserFirstname IS NULL))
AND (([UserMiddleInitial] = @original_UserMiddleInitial)
OR ([UserMiddleInitial] IS NULL
AND @original_UserMiddleInitial IS NULL))">
我有可能收到此错误消息吗?
答案 0 :(得分:0)
bind函数似乎无法将数据库的返回值转换为datetime对象。你能找到datetime的返回值,看看是否可以转换为有效的日期时间吗?