Differences reading XML into listbox in compact framework versus windows forms

  • Thread starter Thread starter John Murray
  • Start date Start date
J

John Murray

can anyone tell me why this same code works on a normal windows
platform but when used in compact framework application produces an
argument exception on setting either the valuemember or displaymember

ds = new DataSet();
string filePath = @"\Program Files\crp3\airf2.xml";
ds.ReadXml(filePath);
this.comboBox1.DataSource=ds;
this.comboBox1.ValueMember="airf2.ICAO";
this.comboBox1.DisplayMember="airf2.AIRFIELD";


TIA

John Murray
 
Hi John:

I don't have the XML file but I use the identical code in many of my apps
and don't have a problem. My guess is that it's the tablename airf2 that's
not being recognized. I'd double check the table count and verify the table
name. You could also just set the source to the table and use just the
field names....
this.comboBox1.DataSource=ds.Tables[0]; //Assuming there's only one table
this.comboBox1.ValueMember="ICAO";
this.comboBox1.DisplayMember="AIRFIELD";

If you want to send me a copy of the xml file, I'll be glad to test it under
both environments and see what I can find... but I'm guessing it's the
tablename.

If you want to send it to me , zing it to my work address wryan At
InfoProGroup Dot Com

(@infoprogroup.com)
--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
 
John,

It's not working because it's not supported. You can not use dots in CF
data binding, anything like "airf2.ICAO" will result in ArgumentExeption.

To make it work, bind to the table, not to the DataSet. This would allow
you to remove dots and will work just fine.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Thanks Ilya
I will givei it a whirl!!



John,

It's not working because it's not supported. You can not use dots in CF
data binding, anything like "airf2.ICAO" will result in ArgumentExeption.

To make it work, bind to the table, not to the DataSet. This would allow
you to remove dots and will work just fine.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
Many thanks William - I have another suggestion about using ( or not)
'.''s so I will try that first


William Ryan eMVP said:
Hi John:

I don't have the XML file but I use the identical code in many of my apps
and don't have a problem. My guess is that it's the tablename airf2 that's
not being recognized. I'd double check the table count and verify the table
name. You could also just set the source to the table and use just the
field names....
this.comboBox1.DataSource=ds.Tables[0]; //Assuming there's only one table
this.comboBox1.ValueMember="ICAO";
this.comboBox1.DisplayMember="AIRFIELD";

If you want to send me a copy of the xml file, I'll be glad to test it under
both environments and see what I can find... but I'm guessing it's the
tablename.

If you want to send it to me , zing it to my work address wryan At
InfoProGroup Dot Com

(@infoprogroup.com)
--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
John Murray said:
can anyone tell me why this same code works on a normal windows
platform but when used in compact framework application produces an
argument exception on setting either the valuemember or displaymember

ds = new DataSet();
string filePath = @"\Program Files\crp3\airf2.xml";
ds.ReadXml(filePath);
this.comboBox1.DataSource=ds;
this.comboBox1.ValueMember="airf2.ICAO";
this.comboBox1.DisplayMember="airf2.AIRFIELD";


TIA

John Murray
 
Back
Top