[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Cannot bind to the new display member. Parameter name: newDisplayMember

Posted on 2014-02-27
4
Medium Priority
?
1,520 Views
Last Modified: 2014-02-28
I'm getting the above error while trying to load a ComboBox. It only occurs on the second execution of the LoadDirectionComboBox() Function. What does this mean? Below is the process of execution.

   'This Sub is executed from a Form Class
    Public Sub LoadDirectionComboBox()
        Try
            InitializeErrorClass(EH)
            BL.LoadDirectionComboBox(EH)

            If EH.DataSet.Tables(0).Rows.Count > 0 Then
                cmbDirection.DataSource = Nothing
                cmbDirection.DataSource = EH.DataSet.Tables(0)
                cmbDirection.DisplayMember = EH.DataSet.Tables(0).Columns(1).ColumnName
                cmbDirection.ValueMember = EH.DataSet.Tables(0).Columns(0).ColumnName
            End If

        Catch ex As Exception
            EH.ErrorMessage = "LoadDirectionComboBox() - " & ex.Message & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
    End Sub
   '
   '
   'This Function initializes an Error Handling Class Objects and is in a Module File
    Public Function InitializeErrorClass(ByRef EH As ErrorHandling.ErrorHandler)
        Try
            EH.DataSet = New DataSet
            EH.DataTable = New DataTable
            EH.Exception = Nothing
            EH.ErrorMessage = ""
            EH.Character = ""
            EH.Bool = False
            EH.Number = 0

        Catch ex As Exception
            EH.ErrorMessage = "InitializeErrorClass() - " & ex.Message & "~E"
        End Try

        Return EH
    End Function
   '
   '
   'This Function resides in my Business Layer
    Public Function LoadDirectionComboBox(ByRef EH As ErrorHandling.ErrorHandler)
        Try
            Dim strFields As String = "direction_ID,direction"
            Dim strTableID As String = "LKUP_Directions"
            Dim strCriteria As String = "active <> 0"
            Dim strOrderBy As String = ""

            DL.GetData(strTableID, strFields, strCriteria, strOrderBy, EH)

        Catch ex As Exception
            EH.ErrorMessage = "LoadDirectionComboBox() - " & ex.Message & "~E"
        End Try

        Return EH
    End Function
   '
   '
   'This Function resides in my Data Layer
    Public Function GetData(ByVal tbl As String, ByVal keyFld As String, ByVal criteria As String, ByVal orderBy As String, ByRef EH As ErrorHandling.ErrorHandler)
        Try
            Dim strCriteria As String = ""
            Dim strOrderBy As String = ""

            DBConnection(EH)

            If EH.Bool Then
                sSQL = "SELECT " & keyFld & " FROM " & tbl

                If criteria.Length > 0 Then
                    strCriteria = " WHERE " & criteria
                    sSQL &= strCriteria
                End If

                If orderBy.Length > 0 Then
                    strOrderBy = " ORDER BY " & orderBy
                    sSQL &= strOrderBy
                End If

                cmd = New SqlCommand(sSQL, cnn)
                adp = New SqlDataAdapter
                adp.SelectCommand = cmd
                adp.Fill(EH.DataSet, 0)
                'adp.Fill(EH.DataSet, "Temp")
            End If

        Catch ex As Exception
            EH.ErrorMessage = "GetData() - " & ex.Message & "...Contact Engineering!" & "~E"
        Finally
            cnn.Dispose()
        End Try

        Return EH
    End Function
   '
   '
   'This Function resides in my Data Layer
    Public Function DBConnection(ByRef EH As ErrorHandling.ErrorHandler)
        Try
            frm.Name = "frmMain"
            cnn = New SqlConnection
            EH.Bool = False

            With cnn
                .ConnectionString = strCNN
                .Open()
                EH.Bool = True
            End With

        Catch ex As Exception
            EH.ErrorMessage = "DBConnection() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try

        Return EH
    End Function

Open in new window

0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39894474
Try changing following

cmbDirection.DisplayMember = EH.DataSet.Tables(0).Columns(1).ColumnName
cmbDirection.ValueMember = EH.DataSet.Tables(0).Columns(0).ColumnName

to

Dim dispMember  As String = EH.DataSet.Tables(0).Columns(1).ColumnName
Dim valMember As String = EH.DataSet.Tables(0).Columns(0).ColumnName
cmbDirection.DisplayMember = dispMember
cmbDirection.ValueMember = valMember
0
 

Author Comment

by:BlakeMcKenna
ID: 39894901
I actually got it working. I moved the DataSource assignment statement beneath the DisplayMember/ValueMember statements and that seemed to work. Not sure why though...
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39894958
Yes that would have been my next option. On random occasions, this fixes the issue especially when reassigning/repopulating the combobox.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 39894975
Thanks for your help!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question