Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
MonthlyLeaders
ASK A QUESTION
Forumguidelines
Aruljothy Sundaramoorthy
1.6k
311
23k
how to solve Cannot bind to the new display member parameter
Apr 19 2018 8:19 PM
I created a window for along with my lined database while I am started debugging my code it showing error like "Cannot bind to the new display member parameter name: new Display member"...
Here is the Code:
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
using
System.Data.OleDb;
namespace
WindowsFormsApplication5
{
public
partial
class
Form2 : Form
{
DataTable dt =
new
DataTable();
static
string
connection = @
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\db\\MobileSpec.mdb;"
;
OleDbConnection conn =
new
OleDbConnection(connection);
public
Form2()
{
InitializeComponent();
}
private
void
Form2_Load(
object
sender, EventArgs e)
{
DataTable dtable =
new
DataTable();
string
sql =
"select Distinct Price from mobilelist"
;
DataTable dtable1 =
new
DataTable();
string
sql1 =
"select Distinct Storage from mobilelist"
;
DataTable dtable2 =
new
DataTable();
string
sql2 =
"select Distinct Storage from mobilelist"
;
try
{
conn.Open();
OleDbDataAdapter da =
new
OleDbDataAdapter(sql, conn);
da.Fill(dtable);
dtable.Columns.Add(
"select Ram"
);
comboBox1.DataSource = dtable;
comboBox1.DisplayMember =
"Desc"
;
comboBox1.ValueMember =
"Ram"
;
comboBox1.SelectedValue =
"select Ram"
;
OleDbDataAdapter da1 =
new
OleDbDataAdapter(sql1, conn);
da1.Fill(dtable1);
dtable1.Columns.Add(
"select Storage"
);
comboBox2.DataSource = dtable1;
comboBox2.DisplayMember =
"Storage"
;
comboBox2.ValueMember =
"Storage"
;
comboBox2.SelectedValue =
"select Storage"
;
OleDbDataAdapter da2 =
new
OleDbDataAdapter(sql2, conn);
da2.Fill(dtable2);
dtable2.Columns.Add(
"select Battery mAh"
);
comboBox3.DataSource = dtable2;
comboBox3.DisplayMember =
"Battery mAh"
;
comboBox3.ValueMember =
"Battery mAh"
;
comboBox3.SelectedValue =
"select Battery mAh"
;
}
catch
(Exception ex)
{
MessageBox.Show(ex.ToString());
}
conn.Close();
}
}
}
Reply
Answers (
3
)
can someone please explain what this code does for me?
Export DataTable to Excel sheet