I have a form with:
textbox roomnumber (table column number int)
combobox roomtype (table column type varchar)
textbox phone (table column phone varchar)
radiobuttons yes or no (table column free varchar)
I have a table with columns:
int number
varchar type
varchar phone
varchar free
I have to enter these values from windows form into table.
I wrote the following code. but do not understand how to get radiobutton values in the insert query.
string free = "";
if (rbyes.Checked)
{
free = "yes";
}
else if (rbno.Checked)
{
free = "No";
}
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into rooms values(number='" + txtroomno.Text + "',type = '" + cbroomtype.SelectedValue.ToString() + "',phone='" + txtphone.Text + "',free)";
cmd.ExecuteNonQuery();
MessageBox.Show("record inserted succeessfully");
Thank you in advance