OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\jay.desai\Documents\Visual Studio 2008\Projects\Test\Test\Test.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("insert into EmpTest values(@Emp_No,@Gender,@Language)", con);
cmd.Parameters.AddWithValue("@Emp_No", textBox1.Text);
if (radioButton1.Checked)
{
cmd.Parameters.AddWithValue("@Gender", radioButton1.Text);
}
else
{
cmd.Parameters.AddWithValue("@Gender", radioButton2.Text);
}
if (checkBox1.Checked)
{
cmd.Parameters.AddWithValue("@Language", checkBox1.Text);
}
if (checkBox2.Checked)
{
cmd.Parameters.AddWithValue("@Language", checkBox2.Text);
}
if (checkBox3.Checked)
{
cmd.Parameters.AddWithValue("@Language", checkBox3.Text);
}
if (checkBox4.Checked)
{
cmd.Parameters.AddWithValue("@Language", checkBox4.Text);
}
cmd.ExecuteNonQuery();
con.Close();
当我点击提交按钮时,只有第一个选中的复选框值插入数据库?