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);
}