Click here to Skip to main content
11,503,151 members (62,368 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi,
i am trying to insert id value passing from previous page to current page but it's giving null exception.
my code is as follow:
.cs file:
protected void btnAdd_Click(object sender, EventArgs e)
   {
       if (objTimberDetails.Insert(Convert.ToInt64(Session["Carting_Challan_ID"].ToString()),
                                   Convert.ToInt32(ddlSpecies.SelectedValue),
                                   txtJungle_no.Text.Trim(),
                                   Convert.ToDouble(txtcoupe_length),
                                   Convert.ToDouble(txtcoupe_girth),
                                   Convert.ToDouble(txtcoupe_cubicmeter),
                                   txtDepot_No.Text.Trim(),
                                   Convert.ToDouble(txtDepot_length),
                                   Convert.ToDouble(txtDepot_girth),
                                   Convert.ToDouble(txtDepot_cubicmeter),
                                   Convert.ToDouble(txtDifference_cubicmeter),
                                   Convert.ToInt32(Session["OfficeID"].ToString())))
       {
           lblStatus.Text = Resources.Language.Common_Record_Add;
       }
       BindGrid(Session["Language"].ToString());

business
logic file:
 public clsTimberDetails()
        {
        }
        public bool Insert(long Carting_Challan_ID,
                           int Species_Id, 
                           string Jungle_no,
                           double coupe_length,
                           double coupe_girth,
                           double coupe_cubic_meter,
                           string Depot_No,
                           double Depot_length,
                           double Depot_girth,
                           double Depot_cubicmeter,
                           double Difference_cubicmeter, 
                           int DIV_ID)
        {
            bool res = false;
            System.Collections.ArrayList sel = new System.Collections.ArrayList();
 
            sel.Add("SP_trn_TimberD_Insert");
            ArrayList lstParam = new System.Collections.ArrayList();
 
            SqlParameter param;
 
            param = new SqlParameter();
            param.ParameterName = "@Carting_Challan_ID";
            param.SqlDbType = SqlDbType.BigInt;
            param.Value = Carting_Challan_ID;
            lstParam.Add(param);
 

            param = new SqlParameter();
            param.ParameterName = "@Species_Id";
            param.SqlDbType = SqlDbType.Int;
            param.Value = Species_Id;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Jungle_no";
            param.SqlDbType = SqlDbType.NVarChar;
            param.Value = Jungle_no;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@coupe_length";
            param.SqlDbType = SqlDbType.Float;
            param.Value = coupe_length;
            lstParam.Add(param);
 
           
            param = new SqlParameter();
            param.ParameterName = "@coupe_girth";
            param.SqlDbType = SqlDbType.Float;
            param.Value = coupe_girth;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@coupe_cubic_meter";
            param.SqlDbType = SqlDbType.Float;
            param.Value = coupe_cubic_meter;
            lstParam.Add(param);
 
            
            param = new SqlParameter();
            param.ParameterName = "@Depot_No";
            param.SqlDbType = SqlDbType.NVarChar;
            param.Value = Depot_No;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Depot_length";
            param.SqlDbType = SqlDbType.Float;
            param.Value = Depot_length;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Depot_girth";
            param.SqlDbType = SqlDbType.Float;
            param.Value = Depot_girth;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Depot_cubicmeter";
            param.SqlDbType = SqlDbType.Float;
            param.Value = Depot_cubicmeter;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Difference_cubicmeter";
            param.SqlDbType = SqlDbType.Float;
            param.Value = Difference_cubicmeter;
            lstParam.Add(param);
 
            
            param = new SqlParameter();
            param.ParameterName = "@DIV_ID";
            param.SqlDbType = SqlDbType.Int;
            param.Value = DIV_ID;
            lstParam.Add(param);
 
            res = new eAuctionDAL.SQLDAL().UpdateTransData(sel, lstParam, false);
            return res;
 
        }


in my sql table i have one more field which is this table's ID which is auto incremented field

what is wrong in this code
pls help.


thanks
Posted 14-Jan-13 4:24am
Edited 14-Jan-13 4:42am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Add two temporary variables and set a breakpoint at the first line.

protected void btnAdd_Click(object sender, EventArgs e)
{
string CartingChallanID = Session["Carting_Challan_ID"].ToString();
string OfficeID = Session["OfficeID"].ToString();
//your code
}

I am sure one of these variables is the culprit.
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100