lorena
Well-known member
I am writing a windows application that interfaces with a SQL database. I want to set up a form that uses data from a parent table (RR_Record) and a child table (RR_Level) based on a value selected by a user from a combobox.
The form loads key values for the parent records with no problem.
When the user selects one of the choices in the ComboBox, the parent record should populate a series of textboxes on the form and the related child records will be a source for a DataGridView on the form.
I created a Data Tier/Data Access Level. Here is the code for that:
Here is the code from the windows form:
At this point, I get "Value of type 1-dimensional array of System.Data.DataRow cannot be converted to System.Data.DataRow"
I know I am missing something huge. I guess I feel this is doable, I am just confused as to how to do it.
Thanks in advance for any help
The form loads key values for the parent records with no problem.
When the user selects one of the choices in the ComboBox, the parent record should populate a series of textboxes on the form and the related child records will be a source for a DataGridView on the form.
I created a Data Tier/Data Access Level. Here is the code for that:
Code:
Public Class RecordAndLevelDataTier
Class level variables for the DataSet and TableAdapters
Private aDataSet As RecordAndLevelDataSet
Private aRecordTableAdapter As RecordAndLevelDataSetTableAdapters.RiskReleaseRecordTableAdapter
Private aLevelTableAdapter As RecordAndLevelDataSetTableAdapters.RiskReleaseLevelTableAdapter
Public Function getRecordAndLevelData() As RecordAndLevelDataSet
Instantiate the DataSet and TableAdapters
aDataSet = New RecordAndLevelDataSet
aRecordTableAdapter = New RecordAndLevelDataSetTableAdapters.RR_RecordTableAdapter
aLevelTableAdapter = New RecordAndLevelDataSetTableAdapters.RR_LevleTableAdapter
Fill both of the adapters
aRecordTableAdapter.Fill(aDataSet.RR_Record)
aLevelTableAdapter.Fill(aDataSet.RR_Level)
Return the dataset
Return aDataSet
End Function
End Class
Here is the code from the windows form:
Code:
Form Level Variables
Dim aRiskReleaseData As New RecordAndLevelDataTier
Dim aDataSet As RecordAndLevelDataSet
Private aBindingSource As BindingSource
Private Sub RiskReleaseForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
aDataSet = aRiskReleaseData.getRecordAndLevelData
aBindingSource = New BindingSource
With aBindingSource
.DataSource = aDataSet
.DataMember = "RiskReleaseRecord"
.Sort = "RiskRelNo"
End With
With Me.rrNoComboBox
.DataSource = aBindingSource
.DisplayMember = "RiskRelNo"
.ValueMember = "RiskRelNo"
.DataBindings.Add("text", aBindingSource, "RiskRelNo", False, DataSourceUpdateMode.Never)
.SelectedIndex = 0
End With
End Sub
Here is the combobox code
Private Sub rrNoComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles rrNoComboBox.SelectedIndexChanged
Dim rrNoString As String
rrNoString = rrNoComboBox.SelectedValue.ToString
Dim aDataSet As New DataSet
Dim recordDataRow As DataRow
recordDataRow = aDataSet.RiskReleaseRecord.FindByRiskRelNo(rrNoString)
Dim levelDataRow() As DataRow
levelDataRow = recordDataRow.GetChildRows("RecordToLevelRelation")
End Sub
At this point, I get "Value of type 1-dimensional array of System.Data.DataRow cannot be converted to System.Data.DataRow"
I know I am missing something huge. I guess I feel this is doable, I am just confused as to how to do it.
Thanks in advance for any help