获得数据库image图片二进制

        /// <summary>
        /// 获得图片二进制
        /// </summary>
        /// <param name="unit_sn">登录用户名</param>
        /// <returns></returns>
        public string GetNameImageFromEmr(string unit_sn)
        {
           
            string sqlCMD = string.Format("Select User_Name_Pic From user_pic Where unit_sn='{0}'", unit_sn);
            DataTable dt = SqlDBHelper.ExcuteDataTable(sqlCMD);
            foreach (DataRow row in dt.Rows)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    object obj = row["User_Name_Pic"];
                    byte[] dd = (byte[])obj;
                    string val = BitConverter.ToString(dd).Replace("-", "");
                    Console.WriteLine(val);
                    return val;
                }
               
            }
            return "";
        }

posted on 2016-08-30 10:19  張暁磊  阅读(231)  评论(0编辑  收藏  举报