?
Solved

Vb Visual Studio binding to SQL

Posted on 2010-01-12
8
Medium Priority
?
271 Views
Last Modified: 2013-11-26
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
Comment
Question by:ourguru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 4

Expert Comment

by:Thunder724
ID: 26297054
What is happening or resulting as an error? What Data type is use for this column in SQL?
0
 

Author Comment

by:ourguru
ID: 26297105
The data type is char(10) and when we run this there are no errors just shows the column as null in SQL
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 26302821
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ourguru
ID: 26303408
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 26303460
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 26554142
I think I supplied a workaround. Lets home the asker responds to tell us whether it worked for him or not.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 26554146
home=hope
:-)
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question