Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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:
C#
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
Updated 14-Jan-13 4:42am
v2

1 solution

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

C#
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.
 
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