By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,774 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,774 IT Pros & Developers. It's quick & easy.

MySql & combo Databinding

P: n/a
Here is my code.

MySqlConnection iCon = new MySqlConnection("Network
Address=localhost;Initial Catalog='invoices'; User
Name='root';Password='tottenham'");
MySqlCommand iCmd = new MySqlCommand("select Acc_Code,Acc_name from
accounts", iCon);
iCon.Open();
MySqlDataReader iRec = iCmd.ExecuteReader();
comboBox1.DataSource = iRec;
comboBox1.DisplayMember = "acc_name";
iCon.Close();

but I am getting an error on the line "Complex DataBinding accepts as a
data source either an IList or an IListSource." on the line
comboBox1.DataSource = iRec.

What am i Doing wrong

Thanks
Ivan
May 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
HI,

"Ivan Sammut" <sa*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Here is my code.

MySqlConnection iCon = new MySqlConnection("Network
Address=localhost;Initial Catalog='invoices'; User
Name='root';Password='tottenham'");
MySqlCommand iCmd = new MySqlCommand("select Acc_Code,Acc_name from
accounts", iCon);
iCon.Open();
MySqlDataReader iRec = iCmd.ExecuteReader();
comboBox1.DataSource = iRec;
comboBox1.DisplayMember = "acc_name";
iCon.Close();

but I am getting an error on the line "Complex DataBinding accepts as a
data source either an IList or an IListSource." on the line
comboBox1.DataSource = iRec.


From the message it seems like if MySqlDataReader does not support IList or
IListSource , which I would find weird.

try to do this:
IList list = iRec;

and see if the compiler complains
May 15 '06 #2

P: n/a
Use

comboBox1.DisplayMember = "accounts.acc_name";

May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.