onlineboy18 0 Newbie Poster

Hi,

I have a form with two radio buttons (radiobutton1 & radiobutton2) "Male and Female". And i tried to implement it by making function and tried to save the data in database but noe succeed. Can anyone help how can i save the checked radio button data in data base using sql query. I am very new in coding so please help in the simple way.
Thanks in advance to all for helping.
This is the code in form load.

string g;
    if (radioButton1.Checked){g = radioButton1.Text.ToString();}
    else{g = radioButton2.Text.ToString();}
    cn = new SqlConnection("server=test;database=pat;user=sa;password=asdasd");
    q = "insert into database values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + gender + "')";

And also how can i retrieve the value from database and make the correct radiobutton checked?