如何将文件名从ASP.net上传控件存储到数据库 [英] How can I store a file name from an ASP.net upload control to a database

查看:93
本文介绍了如何将文件名从ASP.net上传控件存储到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ArtifactSqlDataSource.InsertParameters["ArtifactId"].DefaultValue = txtID.Text;
ArtifactSqlDataSource.InsertParameters["ArtifactType"].DefaultValue = txtType.Text;
ArtifactSqlDataSource.InsertParameters["DateRange"].DefaultValue = txtDateRange.Text;
ArtifactSqlDataSource.InsertParameters["ProvenienceId"].DefaultValue = ddlProvenience.SelectedValue;
ArtifactSqlDataSource.InsertParameters["ImageFile"].DefaultValue = fuImage.PostedFile.FileName.ToString();


fuImage 是文件上传控件的名称.除了图像文件名之外,所有其他所有项都存储到数据库中.


fuImage is the name of the file upload control. All the other items is stored to the database except from the image filename

推荐答案

omanzo_barrett写道:
omanzo_barrett wrote:

ArtifactSqlDataSource.InsertParameters ["ImageFile"].DefaultValue = fuImage.PostedFile.FileName

ArtifactSqlDataSource.InsertParameters["ImageFile"].DefaultValue = fuImage.PostedFile.FileName


看起来不错..什么问题.您已经从上传控件中获取了文件名.您可以像其他值一样保存.

您是否还面临其他任何问题?


Looks fine.. what is the issue. You already got the filename from the upload control. You can save the same like other values.

Are you facing any other issue in it?


是的,这是我的问题,我看不到为什么它不存储在数据库中,因为所有其他项都已存储.我正在使用的数据库是Microsoft SQL Server,我怀疑这是一个问题

UPDATE SM:在调试"模式下,在该行上放置一个断点,然后检查获得的值.首先要确认是否设置了正确的值.如果是这样,则尝试在SQL Server事件探查器中检查什么是传递给数据库以进行数据插入的查询.如果有的话,这将有助于您找到问题所在.
yeah thats my problem I cant see why its is not storing in the database, as all the other items are store. The database that I am using is Microsoft SQL Server, I doubt this is a issue

UPDATE SM: Put a breakpoint at that line while in Debug mode and check what are you getting the value. First thing is to confirm if correct value is being set. If so, then try to check in SQL Server profiler what is the query passed to database for data insert. That would help in getting you where exactly the issue lies, if so.


请参阅下面的Lik

链接
See Lik below

Link


这篇关于如何将文件名从ASP.net上传控件存储到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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