Welcome to Dream.In.Code
Become a VB Expert!

Join 137,232 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,825 people online right now. Registration is fast and FREE... Join Now!




How to add a checked radio button item to a database file

 
Reply to this topicStart new topic

How to add a checked radio button item to a database file

ramper04
22 Feb, 2007 - 02:32 PM
Post #1

New D.I.C Head
*

Joined: 13 Dec, 2006
Posts: 10


My Contributions
Does anybody know how to add a checked radio button item in VB.NET 2003 to a database in MS Access?

CODE
Private Sub mnuOrderAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOrderAdd.Click
        'copy new data to global variables.
        newCustID = lblCustID.Text
        newWholesale = rdWholesale.Checked
        newDesigner = rdDesigner.Checked
        newRetail = rdRetail.Checked
        newShow = txtShow.Text
        newSubtotal = lblSubtotal.Text
        newDiscount = lblDiscount.Text
        newShipping = lblShippingTotal.Text
        newTotal = lblTotal.Text
        'Signal add was clicked and add to record
        Me.DialogResult = DialogResult.OK
        If Me.DialogResult = DialogResult.OK Then
            AddNewOrder()
        End If
    End Sub

    Private Sub AddNewOrder()

        Dim newDataRow As System.Data.DataRow

        newDataRow = DsOrder1.tblOrder.NewRow

        newDataRow.Item("fldPhoneNumber") = newCustID
        newDataRow.Item("fldShow") = newShow
        newDataRow.Item("fldDesigner") = newDesigner
        newDataRow.Item("fldWholesale") = newWholesale
        newDataRow.Item("fldRetail") = newRetail
        newDataRow.Item("fldShipping") = newShipping
        newDataRow.Item("fldSubtotal") = newSubtotal
        newDataRow.Item("fldTotal") = newTotal
        newDataRow.Item("fldDiscount") = newDiscount
        'add the new row to the dataset
        DsOrder1.tblOrder.Rows.Add(newDataRow)
        'update the database file
        daOrder.Update(DsOrder1)
    End Sub


when the program is run and I try to add to the database with one of the radio buttons checked it give back this error: An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: System.FormatException: Input string was not in a correct format.
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Convert.ToInt32(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ToInt32(Object value)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <True> in fldDesigner Column. Expected type is Int32.

Anybody know what needs to be done to fix this?
Thanks in advance.

User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: How To Add A Checked Radio Button Item To A Database File
22 Feb, 2007 - 05:05 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,013



Thanked: 18 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
Are you looking to add checkboxes, or radio buttons, because these are not the same thing.
Radio buttons are grouped such that only 1 may be selected.
Checkboxes allow all or any combination to be selected.
User is offlineProfile CardPM
+Quote Post

ramper04
RE: How To Add A Checked Radio Button Item To A Database File
22 Feb, 2007 - 05:54 PM
Post #3

New D.I.C Head
*

Joined: 13 Dec, 2006
Posts: 10


My Contributions
QUOTE(William_Wilson @ 22 Feb, 2007 - 06:05 PM) *

Are you looking to add checkboxes, or radio buttons, because these are not the same thing.
Radio buttons are grouped such that only 1 may be selected.
Checkboxes allow all or any combination to be selected.


I am looking to add radio buttons because only one (retail,designer, or wholesale) can be selected at a time.

User is offlineProfile CardPM
+Quote Post

Jayman
RE: How To Add A Checked Radio Button Item To A Database File
22 Feb, 2007 - 05:59 PM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
The column that is storing the data in the database must be a Yes/No data type which is set as True/False OR a Text data type.

What is the current structure of your table?
User is offlineProfile CardPM
+Quote Post

ramper04
RE: How To Add A Checked Radio Button Item To A Database File
22 Feb, 2007 - 06:06 PM
Post #5

New D.I.C Head
*

Joined: 13 Dec, 2006
Posts: 10


My Contributions
I have the Designer, Retail, and Wholesale columns set to the yes/no data type, but it still doesn't add them in the database.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: How To Add A Checked Radio Button Item To A Database File
22 Feb, 2007 - 06:10 PM
Post #6

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
What are the data types of the variables in your program?

Also which line is the error message pointing to in your code?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:29PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month