Hello,
I am trying to insert data from textbox to SQL DB table.
When I am clicking on update button, getting below error
Server Error in '/' Application.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 81: protected void Button2_Click(object sender, EventArgs e)
Line 82: {
Line 83: SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());
Line 84: try
Line 85: {
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ToString());
try
{
string query = "insert into Master_Data(Track_Status,Track_MRBDIR, Track_MRBDIRVer,Track_IssueDescr,Track_SrlNo,Track_TOCDIR,Track_Checker,Track_CheckerSAPID,Track_Approver,Track_ApproverSAPID,Track_WP,Track_Material,Track_PriorityLvl,Track_CostCode,Track_MNQty,Track_ForecastD,Track_MRBStatus)values('" + DropDownList1.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox12.Text + "','" + TextBox9.Text + "','" + TextBox13.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + DropDownList2.Text + "','" + TextBox14.Text + "','" + TextBox16.Text + "','" + TextBox17.Text + "','" + DropDownList3.Text + "');";
SqlDataAdapter da = new SqlDataAdapter(query, conn);
conn.Open();
da.SelectCommand.ExecuteNonQuery();
conn.Close();
Updatelbl.Visible = true;
}
catch
{
conn.Close();
}
}
need your expertise to get this issue down.
Thank You