I want to pull a record from my database and either check or uncheck a checkbox, depending on that record. I have 7 different checkboxes that I want this to happen with and each checkbox is tied to a unique field in the table.
- The database's table I'll be pulling from is "ScientificData"
- The field's within the table are: Purple, Navy, Indigo, Green, Yellow, Orange and Red
Question: How do I take the below table data (there are other fields in the table but they are used upon elsewhere - not here so I have left them out of this illustration) and translate the YES records into a checkbox.checked=True and the NO records into a checkbox.check=false? Should a record of ZEROs and ONEs be used for Yes/No records? Is TEXT like YES or NO the way to go here?
It should be noted that EACH of the fields (Purple, Navy, Indigo, Green, Yellow, Orange and Red) are directly related to a single checkbox on the form. That is to say that the form has 7 checkboxes. They are as follow:
1. chkPurple
2. chkNavy
3. chkIndigo
4. chkGreen
5. chkYellow
6. chkOrange
7. chkRed
What should I be looking into or researching in an effort to better understand how to start this portion of my project? Is there a name for this type of return? I'm quite lost here...Obviously.
ScientificData
I don't know if any of my existing code is relevant or not. I suspect some of it is as it calls upon the table already. I'll share a watered down version of what I currently have going on just incase:
Thank you for any help/guidance you can provide.
- The database's table I'll be pulling from is "ScientificData"
- The field's within the table are: Purple, Navy, Indigo, Green, Yellow, Orange and Red
Question: How do I take the below table data (there are other fields in the table but they are used upon elsewhere - not here so I have left them out of this illustration) and translate the YES records into a checkbox.checked=True and the NO records into a checkbox.check=false? Should a record of ZEROs and ONEs be used for Yes/No records? Is TEXT like YES or NO the way to go here?
It should be noted that EACH of the fields (Purple, Navy, Indigo, Green, Yellow, Orange and Red) are directly related to a single checkbox on the form. That is to say that the form has 7 checkboxes. They are as follow:
1. chkPurple
2. chkNavy
3. chkIndigo
4. chkGreen
5. chkYellow
6. chkOrange
7. chkRed
What should I be looking into or researching in an effort to better understand how to start this portion of my project? Is there a name for this type of return? I'm quite lost here...Obviously.
ScientificData
AutoID | Purple | Navy | Indigo | Green | Yellow | Orange | Red |
1 | YES | NO | NO | NO | YES | NO | NO |
2 | NO | NO | NO | NO | YES | YES | NO |
3 | YES | NO | NO | NO | NO | NO | YES |
I don't know if any of my existing code is relevant or not. I suspect some of it is as it calls upon the table already. I'll share a watered down version of what I currently have going on just incase:
Code:
Imports System.Data.SQLite
Public Class frmMain
Private CON As New SQLiteConnection("Data Source= C:\FilePath\The_Database.db;Version=3")
Private WithEvents ScienceAdapter As New SQLiteDataAdapter("SELECT AutoID, ItemName, HardnessA, HardnessB, DensityA, DensityB, Magnetic, Purple, Navy, Indigo, Green, Yellow, Orange, Red, ChemistryID FROM ScientificData", CON)
Private WithEvents ChemistryAdapter As New SQLiteDataAdapter("SELECT AutoID, ChemicalFormula FROM ChemistryData", CON)
Private ScienceDataTable As New DataTable
Private ChemistryDataTable As New DataTable
Private ScienceBindingSource As New BindingSource
Private cmdBldrScience As New SQLiteCommandBuilder(ScienceAdapter)
Private Sub frmMain_Load(Sender As Object, e As EventArgs) Handles Me.Load
ScienceAdapter.Fill(ScienceDataTable)
ChemistryAdapter.Fill(ChemistryDataTable)
Me.cmbChemicalFormula.DisplayMember = "ChemicalFormula"
Me.cmbChemicalFormula.ValueMember = "AutoID"
Me.cmbChemicalFormula.SelectedValue = "AutoID"
Me.cmbChemicalFormula.DataSource = ChemistryDataTable
SetUpBindings()
End Sub
Private Sub SetUpBindings()
ScienceBindingSource.DataSource = ScienceDataTable
Me.txtName.DataBindings.Add("Text", ScienceBindingSource, "ItemName")
Me.txtHardnessA.DataBindings.Add("Text", ScienceBindingSource, "HardnessA")
Me.txtHardnessB.DataBindings.Add("Text", ScienceBindingSource, "HardnessB")
Me.txtDensityA.DataBindings.Add("Text", ScienceBindingSource, "DensityA")
Me.txtDensityB.DataBindings.Add("Text", ScienceBindingSource, "DensityB")
Me.txtMagnetic.DataBindings.Add("Text", ScienceBindingSource, "Magnetic")
Me.cmbChemicalFormula.DataBindings.Add("SelectedValue", ScienceBindingSource, "ChemistryID")
Me.DataGridView1.DataSource = ScienceBindingSource
End Sub