0

我有一个从 ASP.NET 页面调用的存储过程,以获取文件列表和一些相关字段。填充数据集时失败,并且我收到一条错误消息,指出将 varchar 值转换为数据类型 int 时转换失败。该字段指的是具有相对目录路径的varchar。我真的不知道为什么会这样。对此问题的解释和解决方案将不胜感激。我的存储过程如下。

 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

编辑:我阅读失败。对不起。

4

2 回答 2

0

看这条线...

and fldRelativePathName in (select n from @BatchID)

列“n”是一个整数,因此 SQL 试图强制 fldRelativePathName

于 2013-07-16T19:55:01.330 回答
0

and fldRelativePathName in (select n from @BatchID)您不是将字符串fldRelativePathName与整数进行比较吗?

于 2013-07-16T19:55:16.833 回答