title: inserting radio button value in database in c#.net
body: <pre><code>private void btnUpdate_Click(object sender, EventArgs e)
  {
      OleDbConnection con = new OleDbConnection(constr);
      con.Open();
      if (radioButton1.Checked)
      {
          string Sql_radio = "Insert Into tb1(name)Values ('Yes')";
      }
  
      if (radioButton2.Checked)
      {
          string Sql_radio = "Insert Into tb1(name)Values ('no')";
      }
  
      OleDbCommand cmd = new OleDbCommand(Sql_radio, con);
  
  
      cmd.ExecuteNonQuery();
      con.Close();
      MessageBox.Show("Inserted sucessfully");
  }
  </code></pre>
  
  <p>hello.. i am developing a winform application, now i have two radio buttons as you can see in the above code.</p>
  
  <p>i want that if user <code>selects radiobutton1</code> then <code>yes</code> should get inserted in the database and if user <code>selects radiobutton2</code> then it should <code>insert no</code> in the databse.</p>
  
  <p>i have aplied following condition but it is giving an error that the</p>
  
  <blockquote>
    <p>name Sql_radio does not exist in the current context</p>
  </blockquote>
  
  <p>can anyone please tell me the correct way to do the above code?</p>