Loading images from dataset

R

rozrabiak

Hi all :)
I have procedure:

public void czytajObraz()
{
if (datas.Tables["capsch"].Rows.Count > 0)
{
picbox.Image = null;
fig = (byte[])datas.Tables["capsch"].Rows[context[datas,
"capsch"].Position]["Fig"];
if (fig.Length > 0)
{
System.IO.MemoryStream strfig = new System.IO.MemoryStream(fig,
true);
strfig.Write(fig, 0, fig.Length);
Bitmap bmp1 = new Bitmap(strfig);
picbox.Image = bmp1; strfig.Close();
} // if (fig.Length > 0)
}
}

This void is running always when I go to next row, prior row, last or
first in dataset. When I remove data row from dataset (RemoveAt(...) or
Delete()) then I got an exception, otherwise it's work correctly. How
can I read images from dataset when I going up or down in rows?

Thanks for help, gregory.
 
M

Miha Markic [MVP C#]

Hi,

What exception do you get?
What's the context[datas, "capsch"].Position in such condition?
What row are you trying to read?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top