Dim strSQL As String = "select 文件内容 from 合同 where id =" & htid
Dim cmd As New SqlCommand(strSQL, myConnection)
If myConnection.State = ConnectionState.Open Then
Else
myConnection.Open()
End If
Try
Dim wjData() As Byte = cmd.ExecuteScalar()
myConnection.Close()
Dim K As Long
K = UBound(wjData)
Dim fs As New FileStream _
(wjmc, FileMode.Create, FileAccess.Write)
fs.Write(wjData, 0, K)
fs.Close()
fs = Nothing
Response.Redirect("temp\" & file_name)
Catch ex As Exception
'不能完成
Exit Function
End Try
这是我合同下载的代码,改改就行了.
Dim cmd As New SqlCommand(strSQL, myConnection)
If myConnection.State = ConnectionState.Open Then
Else
myConnection.Open()
End If
Try
Dim wjData() As Byte = cmd.ExecuteScalar()
myConnection.Close()
Dim K As Long
K = UBound(wjData)
Dim fs As New FileStream _
(wjmc, FileMode.Create, FileAccess.Write)
fs.Write(wjData, 0, K)
fs.Close()
fs = Nothing
Response.Redirect("temp\" & file_name)
Catch ex As Exception
'不能完成
Exit Function
End Try
这是我合同下载的代码,改改就行了.
解决方案 »
- 积分兑换管理系统 怎么设计?
- 关于打印
- 【分享】iframe去边框,无边框,使用大全
- =如何确定页面是post提交还是get提交=
- 请问session超时,登陆之后怎样进入之前所在的页面呢
- ASP.NET 2.0, 重写Page类OnLoad事件,OnLoad执行,Page_Load事件不执行
- 急呀,救命呀
- 写了一段DataGrid中嵌套CheckBox的代码,但是自己感觉效率过低,高手帮忙分析一下
- 菜鸟问题:确实郁闷
- 调查:非职业程序员的情况(收入,职业,行业,学习编程原因等)
- 思归老大,还在吗???帮我看看这个子窗体传递数据给父窗体都如何触发事件得问题!!!
- 急急急!!!aspnet_wp.exe - 应用程序错误
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
SqlCommand cmd = new SqlCommand(strSql, objConnection); cmd = new SqlCommand(strSql, objConnection);
SqlDataReader objDataReader = cmd.ExecuteReader(); FileStream fs;
BinaryWriter bw;
int bufferSize = 100;
byte[] outbyte = new byte[bufferSize];
string url,jxtName,tpzlName;
string jxtUrl; long retval;
long startIndex = 0; StringCollection tpzlUrls = new StringCollection(); while (objDataReader.Read())
{
if (objDataReader["tpzl"].ToString().Equals("jxt")) {
jxtName = Server.MapPath("Pics/Family/")+objDataReader["record_id"].ToString() + ".jpg";
//////jxtUrl:输出图片
jxtUrl = Request.ApplicationPath + "/Submit/Pics/Family/" + objDataReader["record_id"].ToString() + ".jpg";
EXE.ExecuteSql("update tpzl set path='"+jxtUrl+"' where record_id="+objDataReader["record_id"]);
fs = new FileStream(jxtName, FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs); startIndex = 0;
//关键是下面的命令,其中的5表示的是取objDataReader中读到的第5列image类型数据为参数
retval = objDataReader.GetBytes(5, startIndex, outbyte, 0, bufferSize);
outbyte = (byte[])objDataReader["tpsj"];
bw.Write(outbyte);
bw.Flush();
bw.Close();
fs.Close(); }
}