private DownFileResult SoftUpDate(FileAdr Adress) { DownFileResult message = new DownFileResult(); try { string sqlType = Adress.sqlType; Stream Content; GetConfig(ref sqlType); Byte[] blob = null; DataSet dataSet = new DataSet(); string strSql = "select " + Adress.blobCont + " from " + Adress.dbName + " where " + Adress.primaryKey + " = " + Adress.keyValues; long num = 0; switch (sqlType.Trim().ToUpper()) { case "SQLSERVER": SvrCon.Open(); SqlCommand svrcmd = new SqlCommand(strSql, SvrCon); SqlDataReader svrsdr = svrcmd.ExecuteReader(); SvrCon.Close(); bool svrRead = svrsdr.Read(); blob = new Byte[(svrsdr.GetBytes(0, 0, null, 0, int.MaxValue))]; num = svrsdr.GetBytes(0, 0, blob, 0, blob.Length); svrsdr.Close(); if (num > 0) { Content = new MemoryStream(blob); message.FileStream = Content; message.FileSize = Content.Length; message.Message = num.ToString(); message.IsSuccess = true; } else { Content = null; message.Message = num.ToString(); message.IsSuccess = false; } break; case "ORACLE": OraCon.Open(); OracleCommand oracmd = new OracleCommand(strSql, OraCon); OracleDataReader orasdr = oracmd.ExecuteReader(); OraCon.Close(); bool oraRead = orasdr.Read(); blob = new Byte[(orasdr.GetBytes(0, 0, null, 0, int.MaxValue))]; num = orasdr.GetBytes(0, 0, blob, 0, blob.Length); orasdr.Close(); if (num > 0) { Content = new MemoryStream(blob); message.FileStream = Content; message.FileSize = Content.Length; message.Message = num.ToString(); message.IsSuccess = true; } else { Content = null; message.Message = num.ToString(); message.IsSuccess = false; } break; default: message.Message = "找不到所需的数据库连接类型"; message.IsSuccess = false; break; } return(message); } catch (Exception e) { error = e.Message; message.IsSuccess = false; message.Message = error; return(message); } }
/// <summary> /// 数据库byte下载 /// </summary> /// <param name="dbName">数据库名称</param> /// <param name="blobCont">获取数据列名</param> /// <param name="primaryKey">主键ID</param> /// <param name="keyValues">匹配值</param> /// <param name="sqlType">连接类型</param> /// <returns></returns> public DownFileResult softUpDate(FileAdr Adress) { return(SoftUpDate(Adress)); }