Akhter HUssain

Akhter HUssain

  • 724
  • 1.3k
  • 101.7k

How to insert SessionID into table using asp.net?

Jul 17 2019 2:58 AM
i want to insert Session ID of user into table ,
  1. if (Session["EmpID"] == null)  
  2.            {  
  3.                Response.Redirect("LogingForm.aspx");  
  4.            }  
here is my insert Button code
  1. protected void tbsv_Click(object sender, EventArgs e)  
  2.        {  
  3.   
  4.   
  5.            {  
  6.   
  7.                {  
  8.   
  9.                    if (ddlBbitem.SelectedValue == "")  
  10.                    {  
  11.                        Response.Write("<script>alert('Please Select Item Name')</script>");  
  12.   
  13.                    }  
  14.                    else  
  15.                        if (prdbqty.Text == "")  
  16.                        {  
  17.                            Response.Write("<script>alert('Please Input Weight')</script>");  
  18.   
  19.                        }  
  20.   
  21.   
  22.                        else  
  23.                        {  
  24.                            con.Open();  
  25.                            SqlCommand cmd = new SqlCommand("spInsertbigbale", con);  
  26.                            cmd.CommandType = CommandType.StoredProcedure;  
  27.                            // cmd.Parameters.AddWithValue("@RollNo", TextBox4.Text.Trim());  
  28.                            cmd.Parameters.AddWithValue("@Codeitem", ddlBbitem.SelectedValue);  
  29.   
  30.   
  31.                            cmd.Parameters.AddWithValue("@Bweight", prdbqty.Text.Trim());  
  32.                            cmd.Parameters.AddWithValue("@Bpqty", opbbqty.Text.Trim());  
  33.   
  34.                            cmd.Parameters.AddWithValue("@CID", DDLBBCID.SelectedValue);  
  35.                            cmd.Parameters.AddWithValue("@SecID", DDLBBsec.SelectedValue);  
  36.   
  37.   
  38.                            cmd.Parameters.AddWithValue("@EntryDate", txtbpentrydate.Text);  
  39.                            cmd.Parameters.Add("@BID", SqlDbType.Int);  
  40.                            cmd.Parameters["@BID"].Direction = ParameterDirection.Output;  
  41.   
  42.   
  43.   
  44.   
  45.   
  46.   
  47.   
  48.                            cmd.ExecuteNonQuery();  
  49.   
  50.                            int ResultValue = Convert.ToInt32(cmd.Parameters["@BID"].Value);  
  51.   
  52.                            if (ResultValue > 1)  
  53.                            {  
  54.   
  55.                                Response.Redirect("BigBalePrintView.aspx?BID=" + ResultValue + "");  
  56.                            }  
  57.                            else  
  58.                            {  
  59.                                Response.Write("<script>alert('Record Not save')</script>");  
  60.   
  61.   
  62.                            }  
  63.                            con.Close();  
  64.   
  65.   
  66.   
  67.   
  68.                        }  
  69.                }  
  70.            }  
 

Answers (5)