Setting DisplayMember & ValueMember with DataTable
-
Public Sub s_zoekEntiteit(ByVal i_entiteit As String)
Dim sqlStr As String = "zoekEntiteit '" & i\_entiteit & "'" Dim dataAdapter = New SqlDataAdapter(sqlStr, m\_constring) Dim commandBuilder As New SqlCommandBuilder(dataAdapter) Dim DataGridTable As New DataTable() dataAdapter.Fill(DataGridTable) Form5.ListBox1.DataSource = DataGridTable Form5.ListBox1.DisplayMember = i\_entiteit Form5.ListBox1.ValueMember = i\_entiteit End Sub
The Stored Procedure:
CREATE PROCEDURE zoekEntiteit (@tmpEntiteit nvarchar(40))AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;SELECT @tmpEntiteit FROM tblProduct; --'ByVal i\_prodid As String, ByVal i\_prodnaam As String, ByVal i\_prodomschrijving As String, --'ByVal i\_prodprijs As Int16, ByVal i\_prodinstock As String)
END
The RESULT if @tmpEntiteit would be ProdID : Image to Result What is wrong here I keep getting an error on ' Form5.ListBox1.ValueMember = i_entiteit' the following error : Can't bind to the new DisplayMember. Paramater newDisplayMember
-
Public Sub s_zoekEntiteit(ByVal i_entiteit As String)
Dim sqlStr As String = "zoekEntiteit '" & i\_entiteit & "'" Dim dataAdapter = New SqlDataAdapter(sqlStr, m\_constring) Dim commandBuilder As New SqlCommandBuilder(dataAdapter) Dim DataGridTable As New DataTable() dataAdapter.Fill(DataGridTable) Form5.ListBox1.DataSource = DataGridTable Form5.ListBox1.DisplayMember = i\_entiteit Form5.ListBox1.ValueMember = i\_entiteit End Sub
The Stored Procedure:
CREATE PROCEDURE zoekEntiteit (@tmpEntiteit nvarchar(40))AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;SELECT @tmpEntiteit FROM tblProduct; --'ByVal i\_prodid As String, ByVal i\_prodnaam As String, ByVal i\_prodomschrijving As String, --'ByVal i\_prodprijs As Int16, ByVal i\_prodinstock As String)
END
The RESULT if @tmpEntiteit would be ProdID : Image to Result What is wrong here I keep getting an error on ' Form5.ListBox1.ValueMember = i_entiteit' the following error : Can't bind to the new DisplayMember. Paramater newDisplayMember