views:

21

answers:

1

Getting this after solving a "Error converting data type nvarchar to datetime" error. Using Vb.net/SQL Server 2000 updating a row via a gridview/sqldatasource:

Stored Procedure:

@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 Datasource:

<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>

I'm setting the the Date_Start and Date_End parameters to the minimum date for now until I can figure out what is causing this.

Dim sqldatenull As SqlDateTime
sqldatenull = SqlDateTime.MinValue
e.NewValues("Date_Start") = sqldatenull
e.NewValues("Date_End") = sqldatenull

Any ideas?

A: 

Have you tried using a DateTime in the VB.NET code instead of a SqlDateTime.

codeulike
Disabled the call to sp_changeLog, no change.
Shawn
Changing to DateTime worked! You'd think SqlDateTime would be compatible? Odd indeed.
Shawn
Sorry, edited my answer just as you replied.
codeulike
From the XML defn of the datasource it looks like it prefers a DateTime to a SqlDateTime. Yes, thats odd though.
codeulike