My sql command is throwing null reference exception in asp dot net using c#
This is my code :
SqlConnection cn = new SqlConnection("server=.;database=online_blog;integrated security=true");
cn.Open();
SqlCommand cmd3 = new SqlCommand("UPDATE profiles SET fname = '" + TextBox5.Text + "', lname = '" + TextBox6.Text + "', logname = '" + TextBox7.Text + "', dob = '" + TextBox10.Text + "', highsc = '" + TextBox8.Text + "', coll = '" + TextBox9.Text + "', country = '" + TextBox11.Text + "', state = '" + TextBox12.Text + "', hometown = '" + TextBox13.Text + "', languages = '" + TextBox14.Text + "', aboutme = '" + TextBox15.Text + "', gender = '" + RadioButtonList1.SelectedValue + "', photo = '" + Session["photo"].ToString() + "' where logname = 'saraf' ", cn);
try
{
cmd3.ExecuteNonQuery();
Response.Write(" New Account Updated");
Session["username"] = TextBox7.Text;
}
catch
{
Response.Write("\nerror occured");
}
cn.Close();
Session ["photo"] is initialised....so dont worry about that
The line in which i m creating the new SqlCommand is Throwing Exception
RadioButtonList1.SelectedValueis null