2013-07-16 193 views
0

我有一个存储过程,我从ASP.NET页面调用以获取文件列表和一些相关字段。当数据集被填充时它失败,并且在将varchar值转换为数据类型int时出现错误,表示转换失败。该字段所指的是具有相对目录路径的varchar。我真的不知道为什么会发生这种情况。这个问题的解释和解决方案将不胜感激。我的存储过程如下。将varchar值'/ DirectoryName/SubDirectoryName'转换为数据类型int时转换失败

ALTER proc [dbo].[spFileDownload] 
(
@Folder varchar(1000) = null, 
@Keyword varchar(1000) = null, 
@BatchID IntegerListTable readonly, 
@OrgID IntegerListTable readonly 
) 

as 

if @Keyword is not null 
begin 
    Select fldFileName, 
      fldRelativePathName, 
      fldDescription, 
      fldDateAdded, 
      fldKeywords, 
      fldBatchDescription 
    from tblReport 
    inner join tblBatchLog 
    on tblBatchLog.fldBatchID = tblReport.fldBatchID 
    where fldRelativePathName =ISNULL(@Folder, fldRelativePathName) 
      and Freetext(fldKeywords, @Keyword) 
      and tblreport.fldBatchID in (Select n from @BatchID) 
      and fldMembershipID in (select n from @OrgID) 
end 
else 
begin 
    select fldFileName, 
      fldRelativePathName, 
      fldDescription, 
      fldDateAdded, 
      fldKeywords, 
      fldBatchDescription 
    from tblReport 
    inner join tblBatchLog 
    on tblBatchLog.fldBatchID = tblReport.fldBatchID 
    where fldRelativePathName =ISNULL(@Folder, fldRelativePathName) 
      and fldRelativePathName in (select n from @BatchID) 
      and fldMembershipID in (select n from @OrgID) 
end 

编辑:我在阅读失败。抱歉。

回答

0

and fldRelativePathName in (select n from @BatchID)你不比较字符串fldRelativePathName到整型?

+0

谢谢。我现在觉得没有抓住那个东西。难怪它没有奏效。 – rdittmer

0

看这句话?

and fldRelativePathName in (select n from @BatchID) 

列“n”是这样SQL整数试图强迫fldRelativePathName

相关问题