asp.net编程人士帮我(我初学者)
来源:百度知道 编辑:UC知道 时间:2024/07/03 09:49:14
还有就是,如何应用fileupload控件上传图片至数据库,小妹是初学.net,望各位高手给个例子指导一下编程
请回答问题的人看看清楚,我问的是上传到数据库,不是上传至文件夹,麻烦看清楚问题再回答
使用了一个存储过程,“updateFile”
共三个参数,自己写吧
数据库中文件的数据类型为image
假定数据库中的保存文件的表在pubs库中
所以直接可以用fileupload的属性来实现
///文件流
//System.IO.Stream picStream = this.FileUpload1.PostedFile.InputStream;
//int picSize = this.FileUpload1.PostedFile.ContentLength;
//System.Byte[] b = new byte[picSize];
//picStream.Read(b, 0, picSize);
//文件格式
//string picFormat = this.FileUpload1.PostedFile.ContentType;
string picType = this.FileUpload1.PostedFile.ContentType;
if (picType == "")
{
string picName = this.FileUpload1.FileName;
SqlConnection conn = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
SqlCommand comm = conn.CreateCommand();
comm.CommandType = CommandType.StoredProcedure;
comm.Comma