简体   繁体   English

文件未保存在数据库中

[英]file not save in database

i try to upload document and save in directory and in database also when i upload document it saves in directory but not in database here is upload document code 我尝试上传文档并将其保存在目录和数据库中,当我上传文档时也将其保存在目录中但不在数据库中,这是上传文档代码

if (FileUploadControl.PostedFile != null && FileUploadControl.PostedFile.ContentLength
  < 102400)
        {
            string filename = Path.GetFileName(FileUploadControl.PostedFile.FileName);
            string folder = Server.MapPath("~/Docfiles/");
            Directory.CreateDirectory(folder);
            FileUploadControl.PostedFile.SaveAs(Path.Combine(folder, filename));
            try
            {
                up.fileupladdd(Txt_docde.Value, txt_dname.Value, 
             FileUploadControl.FileName, Convert.ToInt32(DropDownList1.SelectedValue),
            Convert.ToInt32(DropDownList2.SelectedValue), 
            Convert.ToInt32(Session["UserID"]),Convert.ToString(Session["UserID"]));
                StatusLabel.Text = "Success";
            }
            catch
            {
                StatusLabel.Text = "Failed";
            }
        }


        Txt_docde.Value = "";
        txt_dname.Value = "";

and sp of upload file is 和上传文件的sp是

   ALTER procedure [dbo].[fileuplaod]
   @DocDesciption nvarchar(50),
   @DocName nvarchar(50),
   @Uploadfile nvarchar(50),
  @DocTypeID int,
  @DepID int,
  @UserID int
 as
 insert into DocumentInfo(DocDesciption ,DocName,Uploadfile,DocTypeID,DepID ,UserID)
  values(@DocDesciption,@DocName,@Uploadfile,@DocTypeID,@DepID ,@UserID)

where is the problem occur? 问题出在哪里?

当错误试图告诉您时,您正在对非数字的对象调用Convert.ToInt32

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

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