Solved

could not bind to new display member. Parameter name: newDisplayMember

Posted on 2004-09-13
10
1,746 Views
Last Modified: 2008-01-09
I have this function that is supposed to work fine.
Somehow it does not
It gives me error and the combobox has a datarowview for each record.
Solution is a definate 'A'
Help Appreciated.

    Private Sub loadNewInvestors()
        Try
            'Load data for new investor list.

            Dim ssSQL As String
            ssSQL = "ssInvestorsGetList"

            Dim ssCon As SqlConnection = New SqlConnection(eRampConnStr)
            Dim ssCmd As SqlCommand = New SqlCommand(ssSQL, ssCon)
            Dim ssDa As SqlDataAdapter = New SqlDataAdapter(ssCmd)
            Dim loanListDs As DataSet = New DataSet

            ssDa.Fill(loanListDs)

            newInvestor.DataSource = loanListDs
            newInvestor.ValueMember = "company"
            newInvestor.DisplayMember = "orgId"
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

ThanX
0
Comment
Question by:ECIQue
10 Comments
 
LVL 7

Expert Comment

by:ramesh12
ID: 12047757
What is the error. check your sql to have both of the fields that you are using with your newInvestor
0
 
LVL 7

Expert Comment

by:natloz
ID: 12047795
What kind of ssSQL statement is that? A call to a stored procedure or something??? I doesn't look like you are specifying enough information. A sample would be...

'Pass connection string to SqlConnection
                oConn.ConnectionString = strConn

                '******************************
                'Load the Company Dataset Table
                '******************************
                'SQL Database statements
                oComm = New SqlCommand
                oComm.CommandType = CommandType.StoredProcedure
                oComm.CommandText = "spGetAdminCompany"
                oComm.Connection = oConn

                'Send in parameters (0 means all branches)
                oComm.Parameters.Add(New SqlParameter("@pkCompanyID", SqlDbType.Int)).Value = 0

                'create and fill the Data Adapter
                Dim oDa As New SqlDataAdapter(oComm) 'SQL Data Adapter object
                oDa.Fill(_oDsAdmin, "spGetAdminCompany")

                With cboCompany
                    .DataSource = _oDsAdmin.Tables("spGetAdminCompany")
                    .ValueMember = "pkCompanyID"
                    .DisplayMember = "varCompanyCode"
                End With

                cboCompany.SelectedValue = intSelectedCompany

                'Remove parameters
                oComm.Parameters.Clear()

                '*****************************
                'Load the Branch Dataset Tab
0
 

Author Comment

by:ECIQue
ID: 12047798
I have already tried that
This is all alright.

I also treid all suggestions in this discussion

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21040522.html?query=could+not+bind+to+the+new+display+member&topics=323

Let me know
-Smit.
0
 
LVL 7

Expert Comment

by:natloz
ID: 12047825
Is it a stored procedure? Can you post the definition of your stored proc?
0
 
LVL 7

Expert Comment

by:natloz
ID: 12047843
Change your catch to be...

catch ex as exception
  msgbox (ex.tostring)

for a more verbose error message...and post the message.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:ECIQue
ID: 12047951
FYI it is pulling the data into the dataset.
when I go into debug
I tried to check the values and the caption on columns all exist and match the info.

Here is what I mean
This is the debug window info
===========================================
?loanlistds.Tables(0).Columns(0).Caption
"company"

?loanlistds.Tables(0).Columns(1).Caption
"orgId"

?loanlistds.Tables(0).Rows.Count
2

?loanlistds.Tables(0).Rows(0)(0)
"Company Name" {String}
    String: "First NLC Financial Services"

?loanlistds.Tables(0).Rows(0)(1)
"100011010" {String}
    String: "1001959"

?loanlistds.Tables(0).Rows(1)(0)
"Name" {String}
    String: "Name"

?loanlistds.Tables(0).Rows(1)(1)
"1111111" {String}
    String: "1111111"

?loanlistds.Tables(0).Columns.Count
2

Let me knwo how it goes.
I dont think there is any error in data retrival as I can see the data there.
0
 

Author Comment

by:ECIQue
ID: 12048003
System.ArgumentException: Could not bind the new display member
Parameter name: newDisplayMember
  at system.windows.forms.listcontrol.setdataconnection(object newdatasource, bindingmemberinfo newdisplaymember, boolean force)

lemme knwo if that helps
Smit.
0
 
LVL 7

Accepted Solution

by:
natloz earned 500 total points
ID: 12048669
Try this for kicks Smit...just to see....

Right click your solution and ADD ITEM -> Dataset and call it "dsLists"

You will get the yellow screen and click Server Explorer...
Navigate to your SQL database and drag the stored procedure into the window....
Delete the second table it creates called TABLE... and just keep ssInventorsGetList table...
Save and close the dataset....

Now use...
Private Sub loadNewInvestors()
        Try
            'Load data for new investor list.
            Dim ssSQL As String
            ssSQL = "ssInvestorsGetList"

            Dim ssCon As SqlConnection = New SqlConnection(eRampConnStr)
            Dim ssCmd As SqlCommand = New SqlCommand(ssSQL, ssCon)
            Dim ssDa As SqlDataAdapter = New SqlDataAdapter(ssCmd)
            Dim oDs As DataSet = New DataSet("dsLists")

           'create and fill the Data Adapter
           ssDa.Fill(oDs, "ssInventorsGetList")

                             
           With newInvestor
                    .DataSource = oDs.Tables("ssInventorsGetList")
                    .ValueMember = "company" <---NOTE THIS MAY NEED TO BE ORGID ... VALUE IS KEY
                    .DisplayMember = "orgID" <----THIS IS WHAT SHOWS IN COMBO BOX VISUALLY
           End With

                 Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
0
 
LVL 18

Expert Comment

by:DotNetLover_Baan
ID: 12049728
Hi ECIQue,
this is a bad approach to binding...

            newInvestor.DataSource = loanListDs
            newInvestor.ValueMember = "company"
            newInvestor.DisplayMember = "orgId"

ALWAYS bind to a table.

            newInvestor.DataSource = loanListDs.Table(0)
            newInvestor.ValueMember = "company"
            newInvestor.DisplayMember = "orgId"

OR..

while specifying the column titles use proper mapping (TableName.ColumnName)

            newInvestor.DataSource = loanListDs
            newInvestor.ValueMember = "MyTable.company"
            newInvestor.DisplayMember = "MyTable.orgId"

-Baan
0
 

Author Comment

by:ECIQue
ID: 12054033
I already had tried loanListDs.tables(0) and that did not work

any idea why ???
Greatly appreciate all your help.

-Smit.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now