I am retrieving images from a database and displaying using Datalist, but the image loading time is high so need help to optimize it. Here is my code:
public byte[] GetPicture(string Id, string state)
{
byte[] picData = null;
try
{
if (con.State == ConnectionState.Closed)
this.openConnection();
strGetImage = string.Format(strGetImage, Id);
OleDbCommand oledbCommand = new OleDbCommand(strGetImage, con);
picData = (byte[])(oledbCommand.ExecuteScalar());
}
catch (Exception)
{
}
finally
{
con.Close();
}
return picData;
}
You can save Images in some local folder on your drive and then save their paths in DataBase.When You want to retrieve,You can get path from DB and read Image File from that path.