我想通过单选按钮在sql数据库中添加客户的婚姻状况和性别……帮助我,谢谢. [英] i want to add marital status and gender of customer in sql database through radio button......help me plz..Thanx in advance
本文介绍了我想通过单选按钮在sql数据库中添加客户的婚姻状况和性别……帮助我,谢谢.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button2_Click(object sender, EventArgs e)
{
String query = "insert into Limit_account(Account_No,Name,Father_name,Husband_name,CNIC,Date_of_Birth,Nature_of_Business,Permanent_Address,Marital_status,Gender,Amount_paid,Remaining_Amount,Amount_with_markup)values(@Account_No,@Name,@Father_name,@Husband_name,@CNIC,@Date_of_Birth,@Nature_of_Business,@Permanent_Address,@Marital_Status,@Gender,@Amount_Paid,@Remaining_Amount,@Amount_with_markup)";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Prepare();
cmd.Parameters.AddWithValue("@Account_No", txtaccountno.Text);
cmd.Parameters.AddWithValue("@Name", txtname.Text);
cmd.Parameters.AddWithValue("@Father_name", txtfathername.Text);
cmd.Parameters.AddWithValue("@Husband_name", txthusbandname.Text);
cmd.Parameters.AddWithValue("@CNIC", txtcnic.Text);
cmd.Parameters.AddWithValue("@Date_of_birth", dateTimePicker1.Value.Date);
cmd.Parameters.AddWithValue("@Nature_of_Business", txtnatureofbusiness.Text);
cmd.Parameters.AddWithValue("@Permanent_Address", txtpermanentaddress.Text);
//cmd.Parameters.AddWithValue("@Marital_status",????);
//cmd.Parameters.AddWithValue("@Gender",???);
cmd.Parameters.AddWithValue("@Amount_Paid", txtamountpaid.Text);
cmd.Parameters.AddWithValue("@Remaining_Amount", txtremainingamount.Text);
cmd.Parameters.AddWithValue("@Amount_with_markup", txtamountwithmarkup.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("record stored");
}
}
}
推荐答案
private void button2_Click(object sender, EventArgs e)
{
String query = "insert into Limit_account(Account_No,Name,Father_name,Husband_name,CNIC,Date_of_Birth,Nature_of_Business,Permanent_Address,Marital_status,Gender,Amount_paid,Remaining_Amount,Amount_with_markup)values(@Account_No,@Name,@Father_name,@Husband_name,@CNIC,@Date_of_Birth,@Nature_of_Business,@Permanent_Address,@Marital_Status,@Gender,@Amount_Paid,@Remaining_Amount,@Amount_with_markup)";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Prepare();
cmd.Parameters.AddWithValue("@Account_No", txtaccountno.Text);
cmd.Parameters.AddWithValue("@Name", txtname.Text);
cmd.Parameters.AddWithValue("@Father_name", txtfathername.Text);
cmd.Parameters.AddWithValue("@Husband_name", txthusbandname.Text);
cmd.Parameters.AddWithValue("@CNIC", txtcnic.Text);
cmd.Parameters.AddWithValue("@Date_of_birth", dateTimePicker1.Value.Date);
cmd.Parameters.AddWithValue("@Nature_of_Business", txtnatureofbusiness.Text);
cmd.Parameters.AddWithValue("@Permanent_Address", txtpermanentaddress.Text);
if(radiobuttonmale.checked==true)
{
cmd.Parameters.AddWithValue("@Marital_status",radiobuttonmale.Text);
}
if(radiobuttonfemale.checked==true)
{
cmd.Parameters.AddWithValue("@Marital_status",radiobuttonmale.Text);
}
cmd.Parameters.AddWithValue("@Amount_Paid", txtamountpaid.Text);
cmd.Parameters.AddWithValue("@Remaining_Amount", txtremainingamount.Text);
cmd.Parameters.AddWithValue("@Amount_with_markup", txtamountwithmarkup.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("record stored");
}
} }
军事状态也是如此.
谢谢
Same will be for martialstatus.
Thanks
string marital;
if(radiobutton1.checked==true)
{
marital=radiobutton1.text;
}
性别也一样...
same for the gender also...
这篇关于我想通过单选按钮在sql数据库中添加客户的婚姻状况和性别……帮助我,谢谢.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文