Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Friends i am trying the radio information should go in data base but i am not getting it is showing me error

The code which i have writen is

VB
Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        con.ConnectionString = "Data Source=COMP-4\SQLEXPRESS;Initial Catalog=mesco;Integrated Security=True"
        cmd.Connection = con
        cmd.CommandText = "insert into donatetable(donateid,name,age,address,gender,moblieno,email,donationamt)values('"&textname.txt&"','"&txtage.txt&"','"&txtaddress.txt&"','"&RadioButton1.RadioButtonList.&"','"&rbfemale.Select&"','"&&"')"
    End Sub


Can any one help me with the insert code for vb.Net using radio dutton as male and female. and even i am using select @@identity for auto ID generation even this is giving me error plz help
This is my sql query

create table donatetable 
(
name varchar(50),
donorid int,
gender varchar(5),
address varchar(50),
age int,
mobileno int,
email varchar(20),
donationamt int
)



Please help me out with the syntax of radio and it can store in the database
Thanks in advance
Posted
Updated 30-Jan-11 18:18pm
v2

here I'm finding two issues in,

One is with "RadioButton1.RadioButtonList." ==> what this . is working there,

rest if you need to get value of the Selected Radio Button List part then rbfemale.Select will not work. you need to write rbFemale.SelectedValue .Also for this if the selected value from RadioButtonList is a string than it's ok to keep it like '"& YourValue &"' but if its an integer than keep it like "& YouValue &". Just check this thing too.

One more thing the number of columns you are trying to insert values is 8 and the values you are providing is 6. This two numbers must be same. This is also the reason.

MArk as answer if it works.
 
Share this answer
 
Comments
aayu 3-Feb-11 8:42am    
Vishv you told to write is rbfemale.selectvalue but this option is not coming only while and then it is giving error what i do?
Here is the way to get started with RadioButtonList

http://www.java2s.com/Code/ASP/Asp-Control/GetselectedradiobuttonfromradiobuttonlistC.htm[^]

Moreover,
& rbfemale.Select & "','" && "')"
you have an additional & here
 
Share this answer
 
RadioButton1.RadioButtonList.&
I see an additional fullstop here. That could be the reason why you are getting an error.

Make sure the value of the radio button to be stored in the table is the same as the table column type.
 
Share this answer
 
v2
Comments
aayu 31-Jan-11 0:03am    
can you please help me by writing full insert code plz
Abhinav S 31-Jan-11 1:19am    
Just remove the . and try

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900