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: 519
  • Last Modified:

MDI Parent / child form Vb.net

The code below works perfectly when applying it to a "normal" form. If i try to use the same code with a "child" form, it never loads the combobox. Basically i need to know if there is any difference when working with mdi parent and child and regular form. Why does the code work when using a regular form and not when it is a child form.

Thanks

Dim rs As ADODB.Recordset
        Dim MyArray As New ArrayList
        Dim State As SigMap.net_Logic.Common

        'On Error GoTo EH

        rs = New ADODB.Recordset
        State = New SigMap.net_Logic.Common
        rs = State.GetStates

        LoadCombobox(rs, MyArray, "description", "id")

        CropCalcLoss.cmbCrop.DataSource = MyArray

        CropCalcLoss.cmbCrop.DisplayMember = "description"
        CropCalcLoss.cmbCrop.ValueMember = "id"

        rs.Close()

        Exit Sub

EH:
        Err.Description = "LoadStates-> " & Err.Description
        Err.Raise(Err.Number, Err.Source, Err.Description)
0
virgilar
Asked:
virgilar
  • 3
1 Solution
 
TertioptusCommented:
where do you add the combo box to it's parent form's "Controls" collection?
0
 
KudzullcCommented:
virgilar,

Is this VB6 code?  I thought .NET go away from recordsets?
     

        Dim cnOleDb As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\")
        Dim drB2B As OleDb.OleDbDataReader


        cnOleDb.Open()
        Dim cmdB2BCust As New OleDb.OleDbCommand("SELECT * FROM Customers WHERE ID = " & CustIDTextBox.Text & "", cnOleDb)
        drB2B = cmdB2BCust.ExecuteReader
        While drB2B.Read Then
                ParentForm.cmbCrop.Items.Add(drB2B.GetValue(drB2B.GetOrdinal("name")).ToString)        
        End While
        cnOleDb.Close()

This is a .NET approach to building MDI parents with the child form.  Useing OleDb to query data for a fill.

Hope this helps!

Lucas
0
 
KudzullcCommented:
virgilar,

Thanks!  Did this resolve your issue?

Lucas
0
 
virgilarAuthor Commented:
Yes, it did. I am still trying to make the transition between vb 6.0 and .net. Good solution, thanks.

Andre
0
 
KudzullcCommented:
Great!

Thanks, again.

Lucas
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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