Radio button values stored in Database?
In vb.net,
i have 31 PAIRS of radio buttons Yes or No in a web form which will insert the value of radion buttons or text of radio buttons in a single table of 31 columns in SQL server. I grouped each pair of radio button (Y and N). How can I retrieve the selected radio butto开发者_StackOverflow中文版n value of the group and insert it into MS sql server database table using one insert command in VB.Net?
Add a parameter to your SqlCommand like so:
Dim cmd as new sqlcommand("SQL Command Text Here", Conn)
cmd.parameters.add("@FieldA", sqldbtype.bit).value = IIF(FieldAYesChk.Checked, 1, 0)
cmd.parameters.add("@FieldB", sqldbtype.bit).value = IIF(FieldBYesChk.Checked, 1, 0)
cmd.parameters.add("@FieldC", sqldbtype.bit).value = IIF(FieldCYesChk.Checked, 1, 0)
cmd.parameters.add("@FieldD", sqldbtype.bit).value = IIF(FieldDYesChk.Checked, 1, 0)
etc...
Follow link for more information regarding SQL Server Bit data type:
http://msdn.microsoft.com/en-us/library/ms177603.aspx
Explain yourself better:
do you want to store 31 BOOLEAN values in ONE row?
or do you want to store 31 TEXT values in one row?
or do you want to store 31 BOOLEAN and/or TEXT values in 31 columns in one row?
精彩评论