值不能为空。在C#WinApp中 [英] Value cannot be null. in C# WinApp

查看:84
本文介绍了值不能为空。在C#WinApp中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DataSet中创建一个表,它在一个水晶报表中显示多个表,其中一个值是我的代码: -



I Create One table in DataSet that it display Multiple Table in one crystal report with one value this is my code :-

public partial class FRM_RPT_CAR_ID : Form
    {
        int x;

        SqlConnection con = new SqlConnection("Server= .; Database= WhiteWhaleDB; Integrated Security = true");
        SqlCommand sd;
        SqlDataReader sda;
        string s;

        public FRM_RPT_CAR_ID()
        {
            InitializeComponent();
        }

        public FRM_RPT_CAR_ID(string x)
        {
            InitializeComponent();

            this.x = int.Parse(x);
        }

        private void FRM_RPT_CAR_ID_Load(object sender, EventArgs e)
        {
            s = "select s1.Car_id, s1.Change_date , Service_Type.Servce_desc,s1.Current_dist, s1.Prev_distance as Prev_dist, (s1.Current_dist - s1.Prev_dist) as Change_dist ,s1.value_Tashhem as Value from Tashhem s1 INNER JOIN Service_Type ON s1.Servce_id = Service_Type.Servce_id where s1.Car_id" + x;
            DataSet1 ds = new DataSet1();
            SqlDataAdapter dataAdapter = new SqlDataAdapter(s, con);
            dataAdapter.Fill(ds.Tables["Car_details"]);
            CrystalReport_Car_id report = new CrystalReport_Car_id();
            report.SetDataSource(ds.Tables["Car_details"]);
            crystalReportViewer_Car_id.ReportSource = report;
            crystalReportViewer_Car_id.Refresh(); 
        }

推荐答案

正如我在你的另一个问题中告诉你的那样,解决这个问题的最简单方法就是将所有数据库列封装在一个IsNULL语句,用于确保不会收到任何NULL值。
As I told you in your other question the simpliest way to solve this is to encapsulate all database columns in an IsNULL statement to ensure, that no NULL value will be received.


这篇关于值不能为空。在C#WinApp中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆