- 8
- 0
- 约1.16千字
- 约 2页
- 2020-04-22 发布于江西
- 举报
将文件转成流存入数据库
Stream fileDataStream = MyFile.PostedFile.InputStream;//得到文件大小int fileLength = MyFile.PostedFile.ContentLength;//创建数组byte[] fileData = new byte[fileLength];//把文件流填充到数组fileDataStream.Read(fileData,0,fileLength);//得到文件名字string fileTitle = MyFileName.Value;//得到文件类型string fileType = MyFile.PostedFile.ContentType;//构建数据库连接,SQL语句,创建参数SqlConnection connection = new SqlConnection(Server=127.0.0.1;uid=sa;pwd=gotomis;Database=shop);SqlCommand command = new SqlCommand (INSERT INTO TestFiles (MyFileName,MyFile,FileType) +??? VALUES (@MyFileName,@MyFile,@FileType), connectio
原创力文档

文档评论(0)