473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

MySql & combo Databinding

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
2 1645
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
Use

comboBox1.DisplayMember = "accounts.acc_name";

May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CGuy | last post by:
URGENT HELP REQUIRED FROM GURUS Hi, I have a custom object that implements ICollection and IListSource. This object has also an enumerator defined for it which implements IEnumerator and...
1
by: ZZZ | last post by:
I have several combo's with databinding values. when a user starts typen, it's autocompleting so far so good but i don't want the user to have the ability to type a values that's not in the...
10
by: Mike L | last post by:
This is for a Win form. Currently, the first record is shown in the combo box. I want the combo box to be blank and when the user clicks on the down arrow to choose from the list and clicks on...
1
by: Vik | last post by:
Concatenation operator & used in the databinding expressions for the datagrid template columns appears as '&amp;' in HTML. It causes an error when opening the pages. I have to replace '&amp;' by '&' each...
2
by: Jeff Mason | last post by:
I'm observing some strange behavior when I use a bound combo box in conjunction with the combo's anchor property. I define a form which contains just a textbox and a combo box. The text box is...
18
by: Vayse | last post by:
Has anyone an example of filling a combo box with a data reader? Thanks Vayse
5
by: Dennis | last post by:
I am trying to create a form using databinding to a dataset and one of the fields requires the user to select from a list of optons. Any hints on how to do this other than bind the field to a...
5
by: Ivan Sammut | last post by:
Hi ppl, Everyone has a clue how I can do a databinding on a combobox when my data is coming from a MySql database cause the MySqlCommand does not have the ".fill()" procedure. Thanks Ivan
0
by: aine_canby | last post by:
Hi, I'm trying to master databinding but I feel like I'm doing it all wrong. I have a combo which allows me to select a test. I also have the ability to add a test which should result in its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.