比如D:\2007.dat 文件是一个用户定义二进制文件,怎么在SQL Server的image字段读写呢?
解决方案 »
- !!!高分求教,怎么样注册interfax!!!
- combobox 把enabled设为false后字体显示黑色
- 问一个SQL聚合函数的问题
- 关于Word.Application app=new Word.Application()的问题??
- 求C#做的远程桌面例子,内详!奖100分+RMB100元
- 请问,如何得到最靠前窗口的名称
- [百分求助]开发WEB控件的问题
- 请大家帮忙,关于自定义控件继承于抽象类得问题!
- 我只想通过WORD打开指定目录(如:d:\myfile\aa\xxx.doc)的文件,代码怎么写啊???
- 如何显示一个消息框,有是和否 2个按钮?
- 关于两个线程的交互问题,帮帮忙,谢谢!
- 两个WebForm里的数据访问
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=6404
byte[] FileC;
FileC=new Byte[this.FileUp.PostedFile.InputStream.Length];
FileUp.PostedFile.InputStream.Read(FileC, 0,temp); string FName=FileUp.PostedFile.FileName;
FName=FName.Substring(FName.LastIndexOf("\\")+1); myExeSQL.Cmd .Parameters .Add ("@content",System.Data.SqlDbType.Image);
myExeSQL.Cmd.Parameters ["@content"].Value=FileC; string InsterSQL="INSERT INTO resource(title,filename,keyword,type,sender,sub_id,fit_user,source,profile,format,length,makers,content) VALUES ('";
InsterSQL+=this.Ttitle .Text+"','";
InsterSQL+=FName+"','";
InsterSQL+=this.Tkeyword .Text+"','";
InsterSQL+=this.Dsource_kind .SelectedItem .Value+"','";
InsterSQL+=Session["username"].ToString ()+"','";
InsterSQL+=this.Dsubject .SelectedItem .Value+"','";
InsterSQL+=this.Dfit_user .SelectedItem .Value +"','";
InsterSQL+=this.Tsource .Text+"','";
InsterSQL+=this.Tprofile .Text+"','";
InsterSQL+=FileUp.PostedFile.ContentType+"','";
InsterSQL+=temp+"','";
InsterSQL+=this.Tauthor .Text+"',";
InsterSQL+="@content)"; myExeSQL.ExeSQLAction (InsterSQL);
SqlConnection myConnection=new SqlConnection(strConn);
myConnection.Open(); SqlCommand myCommand=new SqlCommand(strSQL,myConnection); SqlDataReader myReader = myCommand.ExecuteReader();
if(myReader.Read())
{
Response.ContentType=myReader["format"].ToString(); //告诉IE文件的MIME类型
// Response.AddHeader ("Content-Disposition","attachment;filename="+myReader["filename"] );
//byte[] Buffer=new Byte[myReader.GetInt16(3)];
//byte Buffer=myReader.GetValue(1);
//Response.BinaryWrite(Buffer);
Response.OutputStream.Write((byte[])myReader["content"], 0, (int)myReader["length"]); }
取的时候把image列转成byte[]类型的,然后赋值给byte[]类型的变量。