Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PictureBox
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
00888944
Message ID:
00888951
Views:
16
Hi Thomas,

In the line of code where you create a new Binding object, you need to alter either the DataSource or the DataMember parameter. What your line of code is doing is binding a DataSet as the DataSource and a field name as the DataMember. In either the DataSource or DataMember parameter, you need to specify which DataTable is being used, even if there is only one in the DataSet. Change the line of code to either of the following:
Binding bdPhoto = new Binding("Image", this.dsEmployeePhotos.Tables[this.oEmployeePhotosBiz.TableName], "Photo");
or
Binding bdPhoto = new Binding("Image", this.dsEmployeePhotos, this.oEmployeePhotosBiz.TableName + ".Photo");
>I have created a form with mmPictureBox.
>
>Following an example at Akadia.com, I have created a databinding as such in the constructor method of an instance of mmMaintenanceForm:
>
>
>InitializeComponent();
>
>// this is essentially the code from Akadia.com, with only a minor
>// change of my own dataset.
>this.dsEmployeePhotos = this.oEmployeePhotosBiz.GetEmployeePhotos();
>Binding bdPhoto = new Binding("Image", this.dsEmployeePhotos, "Photo");
>bdPhoto.Format += new ConvertEventHandler(this.PictureFormat);
>mmPictureBox1.DataBinding.Add(bdPhoto);
>// the constructor method ends here
>....
>private void PictureFormat(object sender, ConvertEventArgs e)
>{
> // e.Value is the original value
> Byte[] img = (Byte[])e.value;
> MemoryStream ms = new MemoryStream();
> // I have also tried int offset = 0
> int offset = 78;
> ms.Write(img, offset, imgLength - offset);
> Bitmap bmp = new Bitmap(ms);
> ms.Close();
>
> // Writes the new value back
> e.Value = bmp;
>}
>
>The exception message I receive is "Cannot bind to property or column Photo on DataSource. Parameter name: dataMember". I have checked the that the column is included in my SELECT statement and have not misspelled it.
>
>Any help is appreciated.
>
>Thanks,
>
>Thomas Allan
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform