ASP.Net: Insert null DateTime
<p>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.</p>

<p>How do you insert a DateTime null. </p>

<p>My SQLDataSource</p>

<pre><code>&lt;asp:SqlDataSource ID="sqldsDetailOrder" runat="server" ConnectionString="&lt;%$ ConnectionStrings:csBookStore %&gt;"
    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"&gt;
    &lt;SelectParameters&gt;
        &lt;asp:ControlParameter ControlID="gvOrdersAdmin" Name="ID" 
            PropertyName="SelectedValue" Type="Int32" /&gt;
    &lt;/SelectParameters&gt;
    &lt;DeleteParameters&gt;
        &lt;asp:Parameter Name="ID" Type="Int32" /&gt;
    &lt;/DeleteParameters&gt;
    &lt;UpdateParameters&gt;
        &lt;asp:Parameter Name="NAME" Type="String" /&gt;
        &lt;asp:Parameter Name="ADDRESS" Type="String" /&gt;
        &lt;asp:Parameter Name="CITY" Type="String" /&gt;
        &lt;asp:Parameter Name="PC" Type="String" /&gt;
        &lt;asp:Parameter DbType="DateTime" Name="DATE" /&gt;
        &lt;asp:Parameter Name="BOOK_ID" Type="Int32" /&gt;
        &lt;asp:Parameter Name="COUNT" Type="Int32" /&gt;
        &lt;asp:Parameter Name="AMOUNT" Type="Decimal" /&gt;
        &lt;asp:Parameter Name="DELIVERED" Type="Boolean" /&gt;
        &lt;asp:Parameter DbType="DateTime" Name="DDATE" /&gt;
        &lt;asp:Parameter Name="PAID" Type="Boolean" /&gt;
        &lt;asp:Parameter DbType="DateTime" Name="PDATE" /&gt;
        &lt;asp:Parameter Name="ID" Type="Int32" /&gt;
    &lt;/UpdateParameters&gt;
    &lt;InsertParameters&gt;
        &lt;asp:Parameter Name="NAME" Type="String" /&gt;
        &lt;asp:Parameter Name="ADDRESS" Type="String" /&gt;
        &lt;asp:Parameter Name="CITY" Type="String" /&gt;
        &lt;asp:Parameter Name="PC" Type="String" /&gt;
        &lt;asp:Parameter DbType="DateTime" Name="DATE" /&gt;
        &lt;asp:Parameter Name="BOOK_ID" Type="Int32" /&gt;
        &lt;asp:Parameter Name="COUNT" Type="Int32" /&gt;
        &lt;asp:Parameter Name="AMOUNT" Type="Decimal" /&gt;
        &lt;asp:Parameter Name="DELIVERED" Type="Boolean" /&gt;
        &lt;asp:Parameter DbType="DateTime?" Name="DDATE" /&gt;
        &lt;asp:Parameter Name="PAID" Type="Boolean" /&gt;
        &lt;asp:Parameter DbType="DateTime" Name="PDATE" /&gt;
    &lt;/InsertParameters&gt;
&lt;/asp:SqlDataSource&gt;
</code></pre>

<p>Thanks Vincent</p>
