我已经在数据库和数据集中设置了日期列可能包含零值。但是,当程序运行时,总是要求填写日期列。错误如下:
其他信息:SQLDATETIME溢出。必须是1/1/1753 12:00:00 AM到12/31/9999 11:59:59 PM。
<div>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="IDREFUNDSELESAI" DataSourceID="RefundSelesaiObjectDataSource">
<Fields>
<asp:BoundField DataField="TANGGAL" HeaderText="TANGGAL" SortExpression="TANGGAL" DataFormatString="{0:d}" />
<asp:ObjectDataSource ID="RefundSelesaiObjectDataSource" runat="server" SelectMethod="GetRefundSelesaiByIdRefund" TypeName="dms_mkph.bll.RefundSelesaiClass" DeleteMethod="DeleteRefundSelesai" InsertMethod="AddRefundSelesai" UpdateMethod="UpdateRefundSelesai" >
<DeleteParameters>
<asp:Parameter Name="idRefundSelesai" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="TANGGAL" Type="DateTime" />
bll.cs
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddRefundSelesai(DateTime TANGGAL)
{
// Create a new ProductRow instance
RefundDataSet.REFUNDSELESAIDataTable dtRefundSelesai = new RefundDataSet.REFUNDSELESAIDataTable();
RefundDataSet.REFUNDSELESAIRow rRefundSelesai = dtRefundSelesai.NewREFUNDSELESAIRow();
if (TANGGAL == null) rRefundSelesai.SetTANGGALNull(); else rRefundSelesai.TANGGAL = TANGGAL;
感谢您的帮助
DateTime
是一个值类型。价值类型不能为空。好吧,除非您使用无效类型
尝试
<asp:Parameter Name="TANGGAL" Type="DateTime?" ConvertEmptyStringToNull="True" />
和
public bool AddRefundSelesai(DateTime? TANGGAL)