ComboBox binding doesn't work!

Snosky

Member
Joined
Dec 28, 2005
Messages
17
Programming Experience
1-3
hi

I have a design layer, a business layer and a data layer.
I want to fill in a the name of the customers with the same familyname in a combobox from en SQL server database. but I get an error!

This I do in the design layer

VB.NET:
Dim k2 As New Klant
k2.zoek_klant_naam(Me.txtKlantNaam.Text)
Me.cboVn = k2.geef_Klantvn
This in the business layer

VB.NET:
Public Sub zoek_klant_naam(ByVal Karakter)
  Dim dv As New DataView
  Dim con As New ClaConnection

  con.conOpen_zoek(Karakter)
  dv = con.geef_dataview()
  mVoornaamcbo.DataSource = dv
  mVoornaamcbo.DisplayMember = "KlantVoornaam"
  mVoornaamcbo.ValueMember = "Klant_ID"
end sub

Property geef_Klantvn() As ComboBox
        Get
            Return Me.mVoornaamcbo
        End Get
        Set(ByVal Value As ComboBox)
            Me.mVoornaamcbo = geef_Klantvn
        End Set
End Property
And this in de data layer

VB.NET:
    Public Function geef_dataview() As DataView
        geef_dataview = dv
    End Function

    Public Sub conOpen_zoek(ByVal Karakter)
  Dim ds As DataSet = New DataSet
 Dim dv As DataView
        Dim sqlStr_zoek As String = "SELECT * FROM Klant k, Gemeenten g WHERE k.gemeente_ID = g.gemeente_ID and k.KlantNaam like '" & Karakter & "%' ORDER BY k.klantVoornaam asc"
        Dim adapter As New SqlDataAdapter(sqlStr_zoek, connection)
        adapter.Fill(ds, "Klant")
        dv = ds.Tables("Klant").DefaultView
    End Sub

It gives an NullReferenceExecption
I did not found an answer on the internet..

Thank you in advance!
 
Back
Top