简体   繁体   English

从DetailsView插入模式将图像上传到数据库

[英]Upload Image to Database From DetailsView Insert Mode

I am attempting to upload an image to a database via a DetailsView containing an UploadFile control in the Edit Item template. 我正在尝试通过DetailsView将图像上载到数据库,该DetailsView在Edit Item模板中包含一个UploadFile控件。

I have a stored procedure which handles the upload to a SQLServer DB which expects two parameters: AuthorName, varchar(20) and AuthorImage, varbin(20). 我有一个存储过程,用于处理向SQLServer DB的上载,该数据库需要两个参数:AuthorName,varchar(20)和AuthorImage,varbin(20)。

The DetailsView is associated with a SQLDataSource: Authors. DetailsView与SQLDataSource:作者相关联。 The Authors data source has the stored procedure as the Insert Command. 作者数据源具有存储过程作为插入命令。

I can grab the binary data from the UploadFile control during the ItemInserting event but I am at a loss as to how to attach the byte array to the AuthorImage parameter. 我可以在ItemInserting事件期间从UploadFile控件中获取二进制数据,但是我对如何将字节数组附加到AuthorImage参数感到困惑。

Any and all assistance appreciated and if possible answers in C# please. 任何和所有帮助表示赞赏,如果可能的话,请用C#回答。

On asp.net you can find the "Personal Site Starter Kit" who handles your problem. 在asp.net上,您可以找到处理您的问题的“个人站点入门套件”。 You can find it on asp.net 你可以在asp.net上找到它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM