2013-09-30 20 views
0

救我試着上傳文檔並保存在目錄和數據庫還 當我上傳文件就可以在目錄中保存,但不是在數據庫 這裏是上傳文件代碼文件不在數據庫中

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) 

問題出現在哪裏?

+0

你得到一個錯誤? – SLaks

+0

不,我沒有得到任何錯誤 – user2832406

+0

當我設置在抓一個破發點就說明我ecpetion「輸入字符串的不正確的格式。」 – user2832406

回答

1

由於錯誤是想告訴你,你打電話Convert.ToInt32的東西,是不是數字。

+0

它是一個USERID ... – user2832406

+0

@ user2832406:那另一個'ToInt32'調用呢? Department ID中的值是否都是整數? – NotMe

+0

沒有droplist1是文檔ID和dropdownlist2是DEP ID – user2832406