I have to get imageData from Database in the form of byte[]. I think i am doing everything right but converting the data to byte[](at the underlined part of code) makes me frustrated. Could someone please help? This is an AsP.net application.
public byte[] getDIImages(int DIImageID)
{
try
{
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@DIImageID",DIImageID )
};
string commandText = "SELECT ImageData, ImageName FROM [DI_Image] WHERE DIImageID =@DI_ImageID";
DataSet pds = new DataSet();
SqlHelper.FillDataset(DbConnString, System.Data.CommandType.Text, commandText, pds, new string[] { "ImageInfo" }, parameters);
# ***Convert.ToByte(pds.Tables[0].Rows[0]["ImageData"]);
return byte1;*** #
}
catch (Exception ex)
{
LogError("Error Occurred When Getting Images : " + PageID.ToString());
return new byte[1];
}
}
Thanks in advance!!
数据应该已经是一个byte[]
:
return (byte[])pds.Tables[0].Rows[0]["ImageData"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.