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文字列を intと比較していませんか?

于 2013-07-16T19:55:16.833 に答える