locked
Parameter is not Valid RRS feed

  • Question

  •  

    Hello Friends..

    I have an imagelist which i want to populate at runtime from the database(SQL Server 2000).My problem is that the code which i have written works fine for some of the images, but for some it gives me the error "Parameter is not Valid".

    I'm, at my wits end.Please Help...

     

    The C#. code is given below:-


    Where, proc_GetIconName – Is the stored procedure
    ICON_NAME – Is the name of the images
    ICON_IMAGE- Is the binary data field
    imglstTree – Is the ImageList which I want to populate at run-time.

     

    public void LoadImageList()
    {
    try
    {
    object[] inParam = new object[1];
    inParam[0] = "";

    drIconImage = dbAccess.GetReader("proc_GetIconName",inParam);
    while (drIconImage.Read())
    {
    try
    {
    string imageName = drIconImage["ICON_NAME"].ToString();
    byte[] image = (byte[])drIconImage["ICON_IMAGE"];
    MemoryStream ms = new MemoryStream();
    ms.Write(image, 0, image.Length);
    imglstTree.Images.Add(imageName, Image.FromStream(ms)); {<<-- Error comes here}
    ms.Close();
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Source + "-" + ex.Message + "-" + ex.Data.Values);
    }
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }

    Monday, April 7, 2008 12:19 PM

Answers

  • It means that the stream doesn't contain valid icon representation. How did you store icons in the database?
    Monday, April 7, 2008 1:03 PM