我想用 asp.net 从 SQL 数据库中检索二进制数据。但是输出中显示的数据与我插入的数据不匹配。这是我的代码:
string EQuery = "SELECT * FROM Ph_Tbl_Contacts WHERE (Contact_ID =" + Contact_ID + ")";
DataSet DSs = new DataSet();
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
DSs = DB.ExecuteQueryData(EQuery);
dt = DSs.Tables[0];
// dr = dt.NewRow();
dr = dt.Rows[0];
byte[] pic;
byte[] raw = (byte[])dr["Contact_CardImage"];
// Session[OpenDialog.STORED_IMAGE] = raw ;
这是插入部分:
byte[] IMAGEbYTE ;
IMAGEbYTE = (byte[])(Session["SessionImage"]);
string Query = "INSERT INTO Ph_Tbl_Contacts (Contact_Name, Contact_LName, " +
"Contact_Company, Contact_Email, Contact_Tel, " +
"Contact_Mobile,Contact_CardImage,Is_Public,User_ID,Save_Date)" +
"VALUES (N'" + Txt_Name.Text + "', N'" + Txt_LastName.Text + "', N'" +
Txt_CompanyName.Text + "', N'" + Txt_Mail.Text + "', N'" +
Txt_Telephone.Text + "', N'" + Txt_Mobile.Text + "','" +
IMAGEbYTE + "','" + CheckValue + "'," +
Session["User_ID"] + ", N'" + DateStr + "')";
DB.ExecuteQueryNoData(Query) ;