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. :(

Re: VB.NET Tally radio button and save the answer in sql database 80 80

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..

Re: VB.NET Tally radio button and save the answer in sql database 80 80

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
Re: VB.NET Tally radio button and save the answer in sql database 80 80

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
Re: VB.NET Tally radio button and save the answer in sql database 80 80

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

radiobutton1.checked

regards

Re: VB.NET Tally radio button and save the answer in sql database 80 80

thank you for the codes!. :)

Re: VB.NET Tally radio button and save the answer in sql database 80 80

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

Re: VB.NET Tally radio button and save the answer in sql database 80 80

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.

Re: VB.NET Tally radio button and save the answer in sql database 80 80

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

Be a part of the DaniWeb community

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