Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Vb Visual Studio binding to SQL

Trying to have the yes,no,N/A radio buttons put in a true,false, or N/A into SQL.
radiobutton 14 = yes, radiobutton 13 =no, and radio button 14 = N/A. not sure if the if statements are needed but they are not working.


Code.jpg
Design.jpg
0
ourguru
Asked:
ourguru
  • 4
  • 2
1 Solution
 
Thunder724Commented:
What is happening or resulting as an error? What Data type is use for this column in SQL?
0
 
ourguruAuthor Commented:
The data type is char(10) and when we run this there are no errors just shows the column as null in SQL
0
 
CodeCruiserCommented:
There are these possible ways of storing such values in the db.

1) Use a smallint datatype and use 1 for yes, 0 for no, -1 for n/a.
2) Use If conditions to translate between the char value stored in db and the checkboxes. For example

If rbYes.Checked Then
   dbvalue="Yes"
ElseIf rbNo.Checked Then
   dbvalue = "No"
Elseif rbNA.Checked Then
   dbvalue = "NA"
End If

Then
If dbvalue = "Yes" Then
   rbYes.Checked = True
ElseIf dbvalue = "No" Then
   rbNo.Checked = True
ElseIf dbvalue = "NA" Then
   rbNa.Checked = True
End If
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ourguruAuthor Commented:
Here is what i have changed the code to
      If radCAYes.Checked Then
            Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("yes")
        ElseIf radCANo.Checked Then
            Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("no")
        ElseIf radCANA.Checked Then
            Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("N/A")
        End If

        If Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("yes") Then
            radCAYes.Checked = True
        ElseIf Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("no") Then
            radCANo.Checked = True
        ElseIf Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("N/A") Then
            radCANA.Checked = True
        End If

I am unsure as to exactly where this need to go. When I run this nothing happens i currently just have it running from just the form. Also do the radio buttons need to be binded to the column or should just specifying the column in the code take care of that?
0
 
CodeCruiserCommented:
I dont understand why you are doing this

Me.PIVDataSet.UK_Inspection.Correct_AdapterColumn.Equals("yes")

If you need to set a value then something like
Me.PIVDataSet.UK_Inspection.Rows(0).Item(2) = "Yes"
 
I am not sure if above is correct as its typed dataset. With untyped, i would do this
dSet.Tables(0).Rows(0).Item("ColumnName") = value
0
 
CodeCruiserCommented:
I think I supplied a workaround. Lets home the asker responds to tell us whether it worked for him or not.
0
 
CodeCruiserCommented:
home=hope
:-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now