DataSet does not support System.Nullable<> exception in c#

后端 未结 5 965
伪装坚强ぢ
伪装坚强ぢ 2021-01-21 01:47
public partial class Form2 : Form
{
        public Form2()
        {
            InitializeComponent();
        }
        private void Form2_Load(object sender, EventArg         


        
5条回答
  •  失恋的感觉
    2021-01-21 02:52

    maybe One of your object values is Null. try something like that

            private void Form2_Load(object sender, EventArgs e)
        {
            RST_DBDataContext db = new RST_DBDataContext();
            var d = (from s in db.TblSpareParts
                                        select new {  
                                                        s.SPartName?? DBNull.Value, 
                                                        s.SPartCode?? DBNull.Value, 
                                                        s.ModelID ?? DBNull.Value, 
                                                        s.SPartLocation ?? DBNull.Value,  
                                                        s.SPartActive ?? DBNull.Value, 
                                                        s.SPartSalePrice ?? DBNull.Value, 
                                                    }).ToArray();
            CrystalReport1 c = new CrystalReport1();
            c.SetDataSource(d);
            crystalReportViewer1.ReportSource = c;
    
        } 
    

提交回复
热议问题