-1
當我將圖像插入SQL Server數據庫時,如果圖像爲空,則會將0x
值插入到數據庫圖像列中。將圖像保存到SQL Server數據庫中
當我取回以0x十六進制值的圖像,我得到一個錯誤:
Parameter is not valid
string strsql = "SELECT [ID],PIC_Name FROM [HRMS].[dbo].[Employee_PC] where Id = '" + mFieldValue1 + "'";
myconn = new OleDbConnection(clsConnections.conString);
myconn.Open();
cmd = new OleDbCommand(strsql, myconn);
OleDbDataReader dr = null;
dr = cmd.ExecuteReader();
while (dr.Read())
{
if ((byte[])dr[1] == null)
//if (picData == null)
{
pictureBox1.Image = null;
}
else
{
MemoryStream ms = new MemoryStream((byte[])dr[1]);
ms.Position = 0;
pictureBox1.Image = new Bitmap(ms);
}
}
檢查,如果從數據庫返回的值不是0X(或爲DBNull) –
*您可以保存*圖像您的數據庫,但我強烈建議你只保存到實際文件的引用。 – Robert