检索存储在数据库中的Doc文件 [英] Retrieving Doc files which is stored in database

查看:95
本文介绍了检索存储在数据库中的Doc文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于检索存储在数据库中的文件的错误。

在我的应用程序中,我需要保存并检索文件。所有文件都以二进制格式正确保存,但是当我尝试检索时,我将检索整个文件为system.Byte []。我想尝试从浏览器窗口打开它只显示System.Byte []。

I have a bug regarding retrieving the file which stored in database.
In my application, I need to save and retrieve the files. All the files are saving properly in a binary format, but coming to retrieving when i am trying to retrieve i’m getting the whole file as "system.Byte[]". And wen iam trying to open it from browser window it is showing only "System.Byte[]".

推荐答案

问题是你如何存储信息,而不是你是如何检索它的。您永远不应该连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。改为使用参数化查询。



这与此处描述的问题完全相同:为什么我得到参数无效。我从数据库中读取图像时出现异常? [ ^ ] - 和完全相同的解决方案。
The problem is how you are storing the information, not how you are retrieving it. You should never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

It's exactly the same problem as described here: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^] - and exactly the same solution.


这篇关于检索存储在数据库中的Doc文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆