Tag: varbinarymax

我应该如何将.doc文档保存到SQL Server数据库

我使用下面的C#代码将.doc文件保存为SQL Server数据库varbinary(max) 。 我能够保存文件,但当我检索文件并想要在网页上显示内容时,我的代码正在下载文件,我对如何处理它感到非常困惑。 我正在寻找的确切function是naukri.com上传简历并预览它的方式。 我的代码是: byte[] fileContent = new byte[fuResume.PostedFile.ContentLength]; fuResume.PostedFile.InputStream.Read(fileContent, 0, fuResume.PostedFile.ContentLength); //lblAppliedMessage.Text = ByteArrayToString(fileContent); //lblAppliedMessage.Text = BitConverter.ToString(fileContent).Replace(“-“, string.Empty); byte[] btYourDoc; btYourDoc = fileContent; Response.ContentType = “application/ms-word”; Response.AddHeader(“Content-Disposition”, “inline;filename=yourfilename.doc”); Response.OutputStream.Write(btYourDoc, 0, fileContent.Length); Response.BinaryWrite(btYourDoc); Response.End();

C#:将图像保存到DB中

有人可以给我一些关于如何在C#中将图像文件保存到DB的建议吗? 我会保存很多图像,那么减少所需空间的最佳方法是什么? 我目前在DB中使用varbinary(max)字段。 谢谢!

C#调整jpg图像,转换为字节并使用varbinary保存到数据库中

我正在尝试调整我使用FileUpload控件上传的jpg图像,并在将其保存到数据库(SQL Server 2008)之前将其转换为byte(varbinary(MAX))。 我所做的和下面的代码显示我设法将其转换为字节并作为varbinary(MAX)保存到数据库中。 我想知道在完成所有这些function之前如何调整图像大小。 帮帮我。 谢谢! 阅读文件 string filePath = FileUpload1.PostedFile.FileName; string filename = Path.GetFileName(filePath); string ext = Path.GetExtension(filename); 根据文件扩展名设置contenttype string contenttype = String.Empty; switch (ext) { case “.jpg”: contenttype = “image/jpg”; break; } 转换为字节并使用varbinary保存到数据库中 if (contenttype != String.Empty) { Stream fs = FileUpload1.PostedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); //insert […]

如何在SQL Server 2008中将Excel文件插入/检索到varbinary(max)列?

我正在尝试将Excel文件保存到数据库中,我不想使用文件流,因为它需要有一个服务器。 那么如何在具有varbinary(max)类型的列的表中插入/更新/选择?

从SQL Server中检索varbinary(MAX)到C#中的byte

我正在尝试从SQL Server获取varbinary(MAX)到C#中的byte[]变量。 我怎样才能做到这一点? 谢谢