文件不保存在数据库中

时间:2013-09-30 21:02:51

标签: c# html asp.net

我尝试上传文档并保存在目录和数据库中 当我上传文件时,它保存在目录中但不保存在数据库中 这是上传文件代码

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 = "";

和上传文件的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)

问题出在哪里?

1 个答案:

答案 0 :(得分:1)

正如错误试图告诉您的那样,您正在对不是数字的内容调用Convert.ToInt32