在解决“将数据类型 nvarchar 转换为日期时间时出错”错误后得到此信息。使用 Vb.net/SQL Server 2000 通过 gridview/sqldatasource 更新一行:
存储过程:
@ISTag varchar(10),
@PCISTag varchar(10),
@User varchar(50),
@Date_Start datetime,
@Date_End datetime,
@Status varchar(50),
@Cost money,
@Notes varchar(500),
@CreatedBy varchar(50),
@ModifiedBy varchar(50)
AS
BEGIN
SET NOCOUNT ON;
EXEC sp_changeLog 'HardDrive', @ISTag, @ModifiedBy
UPDATE T_HardDrive
SET PCIStag = @PCISTag,
[User] = @User,
Date_Start = @Date_Start,
Date_End = @Date_End,
[Status] = @Status,
Cost = @Cost,
Notes = @Notes,
ModifiedBy = @ModifiedBy
WHERE ISTag = @ISTag
SQL 数据源:
<asp:SqlDataSource ID="InventoryHardDrive" runat="server"
ConnectionString="<%$ ConnectionStrings:InventoryConnectionString %>"
DeleteCommand="DELETE FROM [T_HardDrive] WHERE [ISTag] = @original_ISTag"
InsertCommand="sp_HardDriveInsert" InsertCommandType="StoredProcedure"
OldValuesParameterFormatString="original_{0}"
SelectCommand="sp_HardDriveSelect" SelectCommandType="StoredProcedure"
UpdateCommand="sp_HardDriveUpdate" UpdateCommandType="StoredProcedure">
<DeleteParameters>
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ISTag" Type="String" />
<asp:Parameter Name="PCISTag" Type="String" />
<asp:Parameter Name="User" Type="String" />
<asp:Parameter Name="Date_Start" Type="DateTime" />
<asp:Parameter Name="Date_End" Type="DateTime" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="Cost" Type="Decimal" />
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="hideInactiveCheckBox" Name="Active"
PropertyName="Checked" Type="Boolean" />
<asp:ControlParameter ControlID="filterText" DefaultValue="%" Name="ISTag"
PropertyName="Text" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ISTag" Type="String" />
<asp:Parameter Name="PCISTag" Type="String" />
<asp:Parameter Name="User" Type="String" />
<asp:Parameter Name="Date_Start" Type="DateTime" />
<asp:Parameter Name="Date_End" Type="DateTime" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="Cost" Type="Decimal" />
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="CreatedBy" Type="String" />
<asp:Parameter Name="ModifiedBy" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
我暂时将 Date_Start 和 Date_End 参数设置为最小日期,直到我弄清楚是什么原因造成的。
Dim sqldatenull As SqlDateTime
sqldatenull = SqlDateTime.MinValue
e.NewValues("Date_Start") = sqldatenull
e.NewValues("Date_End") = sqldatenull
有任何想法吗?