array list

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
H

Hrvoje Voda

DataRow[] drow = db.dataSetLogo.Logo.Select("LogoName = '" +
cPicList.SelectedItem.ToString() + "'");

if (drow.Length > 0)

{

try

{

picLogo.Image = Image.FromFile(drow[0].ToString ()); *

PicInfo(drow[0].ToString ());

}

catch (Exception x)

{

MessageBox.Show(x.Message);

}

}



I'm using this code to get a name of a logo. But, I get an error on *. How
to get a single name through an array list?



Hrcko
 
What is the error you are seeing? Is it an index out of range exception?
Which could be the case if your drow array is empty. You should always
program defensively and assume that there could be nothing in the array,
rather than trying to access an element which does ot exist.

Mark Dawson
http://www.markdawson.org
 
Hi,


I'm using this code to get a name of a logo. But, I get an error on *. How
to get a single name through an array list?

What the * is doing there? you should be getting a compiler error as this is
a syntax error.

what drow[0].ToString () return?
 
Hrcko,

Since you are guarding against an array of length zero (what if it's null),
I would guess that the file doesn't exist that your tring to load since you
are not using System.IO.File.Exists before attempting to load an image OR
from MSDN:

If the file does not have a valid image format or if GDI+ does not support
the pixel format of the file, this method throws an OutOfMemoryException
exception.

Later,
Dave
 

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

Back
Top