Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I Create One table in DataSet that it display Multiple Table in one crystal report with one value this is my code :-

C#
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(); 
        }
Posted
Comments
Sascha Lefèvre 25-Jan-16 7:59am    
Please show the source for your derived DataSet1.
(Use the "Improve question" link to include it into your question.)
ZurdoDev 25-Jan-16 8:17am    
The error is pretty clear, isn't it? You are putting null somewhere into something that can't have nulls.
Chris Ross 2 25-Jan-16 8:56am    
Have you tried running your code in a debugger ... and seeing what line is throwing the exception?

In the debugger Exceptions dialog (from the Visual Studio Debug menu), tick the 'thrown' column for Common Language Runtime Exceptions - that will make the debugger break when it throws the exception.

The debugger will break on the line that threw the exception - you can now inspect all the variables (and their parts) to see which one is null.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900