ECIQue
asked on
could not bind to new display member. Parameter name: newDisplayMember
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
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
What is the error. check your sql to have both of the fields that you are using with your newInvestor
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.StoredProcedur e
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("spGetAdm inCompany" )
.ValueMember = "pkCompanyID"
.DisplayMember = "varCompanyCode"
End With
cboCompany.SelectedValue = intSelectedCompany
'Remove parameters
oComm.Parameters.Clear()
'************************* ****
'Load the Branch Dataset Tab
'Pass connection string to SqlConnection
oConn.ConnectionString = strConn
'*************************
'Load the Company Dataset Table
'*************************
'SQL Database statements
oComm = New SqlCommand
oComm.CommandType = CommandType.StoredProcedur
oComm.CommandText = "spGetAdminCompany"
oComm.Connection = oConn
'Send in parameters (0 means all branches)
oComm.Parameters.Add(New SqlParameter("@pkCompanyID
'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("spGetAdm
.ValueMember = "pkCompanyID"
.DisplayMember = "varCompanyCode"
End With
cboCompany.SelectedValue = intSelectedCompany
'Remove parameters
oComm.Parameters.Clear()
'*************************
'Load the Branch Dataset Tab
ASKER
I have already tried that
This is all alright.
I also treid all suggestions in this discussion
https://www.experts-exchange.com/questions/21040522/Binding-to-a-ComboBox.html?query=could+not+bind+to+the+new+display+member&topics=323
Let me know
-Smit.
This is all alright.
I also treid all suggestions in this discussion
https://www.experts-exchange.com/questions/21040522/Binding-to-a-ComboBox.html?query=could+not+bind+to+the+new+display+member&topics=323
Let me know
-Smit.
Is it a stored procedure? Can you post the definition of your stored proc?
Change your catch to be...
catch ex as exception
msgbox (ex.tostring)
for a more verbose error message...and post the message.
catch ex as exception
msgbox (ex.tostring)
for a more verbose error message...and post the message.
ASKER
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).Colu mns(0).Cap tion
"company"
?loanlistds.Tables(0).Colu mns(1).Cap tion
"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).Colu mns.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.
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).Colu
"company"
?loanlistds.Tables(0).Colu
"orgId"
?loanlistds.Tables(0).Rows
2
?loanlistds.Tables(0).Rows
"Company Name" {String}
String: "First NLC Financial Services"
?loanlistds.Tables(0).Rows
"100011010" {String}
String: "1001959"
?loanlistds.Tables(0).Rows
"Name" {String}
String: "Name"
?loanlistds.Tables(0).Rows
"1111111" {String}
String: "1111111"
?loanlistds.Tables(0).Colu
2
Let me knwo how it goes.
I dont think there is any error in data retrival as I can see the data there.
ASKER
System.ArgumentException: Could not bind the new display member
Parameter name: newDisplayMember
at system.windows.forms.listc ontrol.set dataconnec tion(objec t newdatasource, bindingmemberinfo newdisplaymember, boolean force)
lemme knwo if that helps
Smit.
Parameter name: newDisplayMember
at system.windows.forms.listc
lemme knwo if that helps
Smit.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
I already had tried loanListDs.tables(0) and that did not work
any idea why ???
Greatly appreciate all your help.
-Smit.
any idea why ???
Greatly appreciate all your help.
-Smit.