客户端:
<INPUT id="myfile" style="Z-INDEX: 101; LEFT: 14px; POSITION: absolute; TOP: 13px" type="file" name="myfile" runat="server">服务器端:
if(this.myfile.PostedFile!=null)
{
System.IO.Stream fs=this.myfile.PostedFile.InputStream;
byte[] flob=new byte[fs.Length];
int n= fs.Read(flob,0,(Int32)fs.Length);
dbconn.ConnectionString=Public.PuBDataBase.DBconnectiongstring;
dbconn.Open();
dbcmd.UpdateCommand.Connection=dbconn;
dbcmd.UpdateCommand.CommandText="update doc_table set a1=? where a0=2";
dbcmd.UpdateCommand.Parameters.Add("a1",System.Data.OleDb.OleDbType.Binary);
dbcmd.UpdateCommand.Parameters["a1"].Value=flob;
dbcmd.UpdateCommand.ExecuteNonQuery();
dbcmd.UpdateCommand.CommandText="commit";
dbcmd.UpdateCommand.ExecuteNonQuery();
}
这就是写道数据库(oracle 8i a1 long raw子段)
<INPUT id="myfile" style="Z-INDEX: 101; LEFT: 14px; POSITION: absolute; TOP: 13px" type="file" name="myfile" runat="server">服务器端:
if(this.myfile.PostedFile!=null)
{
System.IO.Stream fs=this.myfile.PostedFile.InputStream;
byte[] flob=new byte[fs.Length];
int n= fs.Read(flob,0,(Int32)fs.Length);
dbconn.ConnectionString=Public.PuBDataBase.DBconnectiongstring;
dbconn.Open();
dbcmd.UpdateCommand.Connection=dbconn;
dbcmd.UpdateCommand.CommandText="update doc_table set a1=? where a0=2";
dbcmd.UpdateCommand.Parameters.Add("a1",System.Data.OleDb.OleDbType.Binary);
dbcmd.UpdateCommand.Parameters["a1"].Value=flob;
dbcmd.UpdateCommand.ExecuteNonQuery();
dbcmd.UpdateCommand.CommandText="commit";
dbcmd.UpdateCommand.ExecuteNonQuery();
}
这就是写道数据库(oracle 8i a1 long raw子段)
解决方案 »
- 关键词设置怎么做啊?
- showmodaldialog 关闭父窗口
- vs.net 2008 RTM版无法添加jquery intellisense的解决方法
- |zyciis| 如何更改paipal的收货人信息,我根据网上的文档将值传过去,但paypal显示的收货地址还是在paypal中注册时填写的收货地址,谢谢
- 推荐 申请免费静态域名空间 网站 ?
- 打印ActiveX被IE屏蔽,如何处理?
- 请问哪里有支持ASP.net的虚拟主机网站,原来有人提供找不到了
- 字符串中有几个字符是 Unicode编码,而这个系统是gb2312编码,如果把这几个字符转换为gb2312
- 我只是来散分的!!!!
- 如何用JAVASCRIPT得到WEBCONTORL的TREEVIEW控件中所有CHECKBOX为选中状态的节点
- 如何将XXX. aspx.cs中的变量转到.aspx的Html代码中.
- 急急,怎么把DataGrid数据导成Excel文件?谢谢!
//添加新记录的同时上传attach file
SqlDataAdapter myCommand1 = new SqlDataAdapter("SELECT MAX(id) AS maxid FROM sampleTable", myConnection);
DataSet ds = new DataSet();
myCommand1.Fill(ds, "sampleTable");
foreach( DataRow app in ds.Tables["sampleTable"].Rows) {
Text1.Value =app["maxid"].ToString() ;
}
if (checkbox1.Checked ==true){
//if File1.Value
try{File1.PostedFile.SaveAs("E:\\upload\\"+Text1.Value+ ".pdf");
Message.InnerHtml = "<b>File uploaded successful</b><br>";
Message.Style["color"] = "blue";
}
catch (Exception exc)
{
Message.InnerHtml = "<b>Error in uploading file</b><br>";
Message.Style["color"] = "red";
} //更新table中新插入记录的字段[attachfile].即加入超级链接。
String updateCmd = "UPDATE sampleTable SET attachfile = @attachfile where id = "+Text1.Value;
SqlCommand myCommand2 = new SqlCommand(updateCmd, myConnection);
myCommand2.Parameters.Add(new SqlParameter("@attachfile", SqlDbType.NVarChar, 50));
myCommand2.Parameters["@attachfile"].Value = "/cattach/" + Text1.Value + ".pdf";
myCommand2.Connection.Open();
try
{
myCommand2.ExecuteNonQuery();
Message.InnerHtml = "<b>Record updated</b><br>";
Message.Style["color"] = "blue";
}
catch (SqlException e)
{
Message.InnerHtml = "<b>ERROR: Could not update record, please ensure the fields are correctly filled out!</b>";
Message.Style["color"] = "blue";
}
myCommand2.Connection.Close();
BindGrid2();
}