Hey
I'am using a SQLDatasource in combination with a Formview.
When I want to insert or update a DateTime that has no value, I always get an error.
How do you insert a DateTime null.
My SQLDataSource
<asp:SqlDataSource ID="sqldsDetailOrder" runat="server" ConnectionString="<%$ ConnectionStrings:csBookStore %>"
SelectCommand="SELECT 'AUTHOR' = tblAuthors.FIRSTNAME + ' ' + tblAuthors.LASTNAME, tblBooks.*, tblGenres.*, tblLanguages.*, tblOrders.* FROM tblAuthors INNER JOIN tblBooks ON tblAuthors.AUTHOR_ID = tblBooks.AUTHOR_ID INNER JOIN tblGenres ON tblBooks.GENRE_ID = tblGenres.GENRE_ID INNER JOIN tblLanguages ON tblBooks.LANG_ID = tblLanguages.LANG_ID INNER JOIN tblOrders ON tblBooks.BOOK_ID = tblOrders.BOOK_ID WHERE tblOrders.ID = @ID"
DeleteCommand="DELETE FROM [tblOrders] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [tblOrders] ([NAME], [ADDRESS], [CITY], [PC], [DATE], [BOOK_ID], [COUNT], [AMOUNT], [DELIVERED], [DDATE], [PAID], [PDATE]) VALUES (@NAME, @ADDRESS, @CITY, @PC, @DATE, @BOOK_ID, @COUNT, @AMOUNT, @DELIVERED, @DDATE, @PAID, @PDATE)"
UpdateCommand="UPDATE [tblOrders] SET [NAME] = @NAME, [ADDRESS] = @ADDRESS, [CITY] = @CITY, [PC] = @PC, [DATE] = @DATE, [BOOK_ID] = @BOOK_ID, [COUNT] = @COUNT, [AMOUNT] = @AMOUNT, [DELIVERED] = @DELIVERED, [DDATE] = @DDATE, [PAID] = @PAID, [PDATE] = @PDATE WHERE [ID] = @ID">
<SelectParameters>
<asp:ControlParameter ControlID="gvOrdersAdmin" Name="ID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="NAME" Type="String" />
<asp:Parameter Name="ADDRESS" Type="String" />
<asp:Parameter Name="CITY" Type="String" />
<asp:Parameter Name="PC" Type="String" />
<asp:Parameter DbType="DateTime" Name="DATE" />
<asp:Parameter Name="BOOK_ID" Type="Int32" />
<asp:Parameter Name="COUNT" Type="Int32" />
<asp:Parameter Name="AMOUNT" Type="Decimal" />
<asp:Parameter Name="DELIVERED" Type="Boolean" />
<asp:Parameter DbType="DateTime" Name="DDATE" />
<asp:Parameter Name="PAID" Type="Boolean" />
<asp:Parameter DbType="DateTime" Name="PDATE" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="NAME" Type="String" />
<asp:Parameter Name="ADDRESS" Type="String" />
<asp:Parameter Name="CITY" Type="String" />
<asp:Parameter Name="PC" Type="String" />
<asp:Parameter DbType="DateTime" Name="DATE" />
<asp:Parameter Name="BOOK_ID" Type="Int32" />
<asp:Parameter Name="COUNT" Type="Int32" />
<asp:Parameter Name="AMOUNT" Type="Decimal" />
<asp:Parameter Name="DELIVERED" Type="Boolean" />
<asp:Parameter DbType="DateTime?" Name="DDATE" />
<asp:Parameter Name="PAID" Type="Boolean" />
<asp:Parameter DbType="DateTime" Name="PDATE" />
</InsertParameters>
</asp:SqlDataSource>
Thanks Vincent