array list

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hrvoje Voda

    #1

    array list

    DataRow[] drow = db.dataSetLogo. Logo.Select("Lo goName = '" +
    cPicList.Select edItem.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


  • Mark R. Dawson

    #2
    RE: array list

    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


    "Hrvoje Voda" wrote:
    [color=blue]
    > DataRow[] drow = db.dataSetLogo. Logo.Select("Lo goName = '" +
    > cPicList.Select edItem.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
    >
    >
    >[/color]

    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: array list

      Hi,


      [color=blue]
      >
      > 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?[/color]

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

      what drow[0].ToString () return?



      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation


      Comment

      • D. Yates

        #4
        Re: array list

        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 OutOfMemoryExce ption
        exception.

        Later,
        Dave

        "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
        news:dsf7lp$q1r $1@ss405.t-com.hr...[color=blue]
        > DataRow[] drow = db.dataSetLogo. Logo.Select("Lo goName = '" +
        > cPicList.Select edItem.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
        >
        >[/color]


        Comment

        Working...