我正在从数据库中检索图像并使用 Datalist 显示,但是图像加载时间很长,因此需要帮助来优化它。这是我的代码:
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;
}