如何通过单选按钮在sql server中插入值 [英] how to insert values in sql server through radio button

查看:78
本文介绍了如何通过单选按钮在sql server中插入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前使用此代码进行插入操作但是我想保存radiobutton值



i previously use this code for insert operation but along with this i want to save the radiobutton values

cmd.CommandText = "INSERT INTO Table1 (username,password,gender) VALUES (@username,@password,gender)";
           cmd.Parameters.AddWithValue("@username", textBox1.Text);
           cmd.Parameters.AddWithValue("@password", textBox2.Text);



i有两个男性和女性的单选按钮,我想在数据库中只保存一个值,所以我使用groupbox只选择一个单选按钮但是如何插入数据库。作为男性或女性


i have two radio buttons for male and female, i want to save only one value in the database so i have used groupbox for selecting only one radio button but how to insert into database. as male or female

推荐答案

http://stackoverflow.com/questions/5325434/radiobutton-data-want-to-be-send-to-the-database [ ^ ]

http: //stackoverflow.com/questions/5605666/how-to-insert-data-using-radio-buttons-in-windows-application-c-sharp-dotnet-and [ ^ ]

插入单选按钮值es到SQL Server 2005数据库 [ ^ ]

http://stackoverflow.com/questions/13939411/how-to-insert-values-in-sql-server-through-radio-button [ ^ ]
http://stackoverflow.com/questions/5325434/radiobutton-data-want-to-be-send-to-the-database[^]
http://stackoverflow.com/questions/5605666/how-to-insert-data-using-radio-buttons-in-windows-application-c-sharp-dotnet-and[^]
Insert radio button values to a SQL Server 2005 Database[^]
http://stackoverflow.com/questions/13939411/how-to-insert-values-in-sql-server-through-radio-button[^]


if(!rdomake.checked &&!rdofemale.checked)

//显示验证消息

否则如果(rdomale.checked)

cmd.Parameters.AddWithValue(@ gender,male);

slee if(rdofemale.checked)

cmd.Parameters.AddWithValue(@ gender,female;
if(!rdomake.checked && !rdofemale.checked)
//show validation msg
else if(rdomale.checked)
cmd.Parameters.AddWithValue("@gender", "male);
slee if(rdofemale.checked)
cmd.Parameters.AddWithValue("@gender", "female);


这篇关于如何通过单选按钮在sql server中插入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆