Good day!.
I have here a form in vb.net. It contain a groupbox named question and it has a 5 radio buttons. My problem is if i choose my answer in a radio buttons, how it can show the answer in my sql database?
please help me. :(

Recommended Answers

All 8 Replies

So you want to store the radio button state into database. If i am right then just check the values or all radio button by using

RadioButton1.Checked

Now suppose you have a table where a field for saving the state is [rad]

then find which radio button is checked and store its number or index..

Good day!.
I have here a form in vb.net. It contain a groupbox named question and it has a 5 radio buttons. My problem is if i choose my answer in a radio buttons, how it can show the answer in my sql database?
please help me. :(

If radio.check = true then
       'sql

Good day!.
I have here a form in vb.net. It contain a groupbox named question and it has a 5 radio buttons. My problem is if i choose my answer in a radio buttons, how it can show the answer in my sql database?
please help me. :(

try this logic.

If radio1.check =true then
      'sql statement
      insert into table (columnAnswer) values ('theAnswer')

     else If radio2.check =true then
       'sql statement
      insert into table (columnAnswer) values ('theAnswer')
     
     else If radio3.check =true then
       'sql statement
      insert into table (columnAnswer) values ('theAnswer')

     else If radio4.check =true then
       'sql statement
      insert into table (columnAnswer) values ('theAnswer')
     
     else If radio5.check =true then
       'sql statement
      insert into table (columnAnswer) values ('theAnswer')
      End if

first the datatype of your field is bit , then use above mentioned code to save the value of your radio button.

radiobutton1.checked

regards

thank you for the codes!. :)

if your prob is solved , please mark this thread solved.

If radio1.check =true then
'sql statement
insert into table (columnAnswer) values ('theAnswer')
else If radio2.check =true then
'sql statement
insert into table (columnAnswer) values ('theAnswer')

else If radio3.check =true then
'sql statement
insert into table (columnAnswer) values ('theAnswer')

else If radio4.check =true then
'sql statement
insert into table (columnAnswer) values ('theAnswer')

else If radio5.check =true then
'sql statement
insert into table (columnAnswer) values ('theAnswer')
End if

i try this code but it there's an error when i try to connect to my sql database. help me please.

sir what about if you are using access database???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.