Click here to Skip to main content
12,398,557 members (58,131 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET

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

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 30-Jan-11 17:52pm
Updated 30-Jan-11 18:18pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Aarti2010 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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Here is the way to get started with RadioButtonList[^]

& rbfemale.Select & "','" && "')"
you have an additional & here
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 2 Feb 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100