如何在 RDLC 文本框中显示大量数据

发布于 2024-11-03 11:36:43 字数 429 浏览 1 评论 0原文

我有一个 rdlc 报告,它显示从 Microsoft SQL 2008 数据库中的单个文本字段检索到的转录信息。该报告很简单,由一个短标题和一个包含单个文本框的正文组成。我们遇到的问题是一些报告数据被切断。没有错误信息就被切断了。经过一些测试,我们确定文本框截断了大约 32,000 个字符。在这个发现之后,我做了一些研究,我发现唯一有用的是对 msdn social.msdn 我们遇到的一些转录包含 500,000 个字符,我们无法知道这个数字是否会增加。有什么办法可以解决报告文本框 32,000 个字符的限制吗?

I have an rdlc report which displays transcribed information retrieved from a single text field in a Microsoft SQL 2008 database. The report is simple in that it consists of a short header, and a body which contains a single textbox. The issue we are having is some of the report data is cut off. No error message just cut off. After some testing we determined the textbox cuts off around 32,000 characters. After this discovery I did some research and the only thing I found useful was a reference to msdn social.msdn
Some of the transcriptions we are running into contain 500,000 characters and we have no way to know if that will not go up. Is there any way around what appears to be the report’s textbox 32,000 character limit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硪扪都還晓 2024-11-10 11:36:43

我想出的解决方案是编写一些 T-SQL 来分解大文本块
分成更小的部分,然后返回一个表,其中每 30,000 个字符的文本块包含一行。然后在报告上将我的文本框放入列表中。
下面是 SQL

declare @transcriptionBody TABLE 
(
    SegmentNumber int identity(1,1),
    BodyPart nvarchar(max)
)
declare 
    @bodyPart varchar(max),
    @body nvarchar(max),
    @indexToLastNewLineInBodyPart int,
    @lenOfBody int,
    @MAX_CHARACTERS int,
    @numberOfCharactersLeftInString int,
    @position int

set @MAX_CHARACTERS = 30000
set @indexToLastNewLineInBodyPart = 0
set @numberOfCharactersLeftInString = 0
set @position = 0

/*
 *  Get the long string of characters from your database. In this example the 
 *  [Body] field is a text field.
*/
select @body = Body from [Transcription] with(nolock) where Id = @TranscriptionId
set @lenOfBody = len(@body)

/*
 *  Loop through the @body variable chopping up the string into managable chuncks
 *  and inserting those chuncks into a table variable called @transcriptionBody.
 *  The loop exists when the 
*/
while (@position < @lenOfBody)
begin

    /*
     *  If the transcription body is less than 30,000 then insert it into
     *  our table variable and return.
    */
    if (@lenOfBody <= @MAX_CHARACTERS and @position = 0)
    begin
        insert into @transcriptionBody(BodyPart) values(@body)
        set @position = @lenOfBody
    end

    /*
     *  Otherwise we need do the following
     *  1.  Get the number of chars in the string starting from the input start index.
     *  2.  If the number of chars in the string is > than the max allowable chars then
     *      substring off the first 30,000 chars into a body part.
     *      
     *      2a. Now have a string consisting of 30,000 chars but you have no idea where it
     *          cut off (it could be in the middle of a word). So you now need to get the 
     *          index of the last newline and re-break the string on that.Then insert it
     *          into the table variable and set the position.
     *
     *  3.  If the number of chars in the string IS NOT > than the max allowable chars
     *      then substring off the remaining chars into a body part and insert it into our
     *      table variable
    */
    else
    begin
        -- 1.
        select @numberOfCharactersLeftInString = (@position - @lenOfBody) * -1

        -- 2.
        if (@numberOfCharactersLeftInString > @MAX_CHARACTERS)
        begin
            select @bodyPart = substring(@body, @position, @MAX_CHARACTERS)

            -- 2a.
            select @indexToLastNewLineInBodyPart = Len(@bodyPart) - charindex(char(13)+char(10),reverse(@bodyPart))
            if (@indexToLastNewLineInBodyPart > 0)
            begin
                select @bodyPart = substring(@bodyPart,@position,@indexToLastNewLineInBodyPart)
                insert into @transcriptionBody(BodyPart) values(@bodyPart)
                select @position = @position + len(@bodyPart)
            end     
        end
        else
        begin
            select @bodyPart = substring(@body, @position, @numberOfCharactersLeftInString)
            insert into @transcriptionBody(BodyPart) values(@bodyPart)
            select @position = @position + len(@bodyPart)
        end 
    end
end
select * from @transcriptionBody order by SegmentNumber

The solution I came up with was to write some T-SQL to break up the large block of text
into smaller pieces, and then return a table containing a row for every 30,000 char block of text. Then on the report place my textbox in a list.
Below is the SQL

declare @transcriptionBody TABLE 
(
    SegmentNumber int identity(1,1),
    BodyPart nvarchar(max)
)
declare 
    @bodyPart varchar(max),
    @body nvarchar(max),
    @indexToLastNewLineInBodyPart int,
    @lenOfBody int,
    @MAX_CHARACTERS int,
    @numberOfCharactersLeftInString int,
    @position int

set @MAX_CHARACTERS = 30000
set @indexToLastNewLineInBodyPart = 0
set @numberOfCharactersLeftInString = 0
set @position = 0

/*
 *  Get the long string of characters from your database. In this example the 
 *  [Body] field is a text field.
*/
select @body = Body from [Transcription] with(nolock) where Id = @TranscriptionId
set @lenOfBody = len(@body)

/*
 *  Loop through the @body variable chopping up the string into managable chuncks
 *  and inserting those chuncks into a table variable called @transcriptionBody.
 *  The loop exists when the 
*/
while (@position < @lenOfBody)
begin

    /*
     *  If the transcription body is less than 30,000 then insert it into
     *  our table variable and return.
    */
    if (@lenOfBody <= @MAX_CHARACTERS and @position = 0)
    begin
        insert into @transcriptionBody(BodyPart) values(@body)
        set @position = @lenOfBody
    end

    /*
     *  Otherwise we need do the following
     *  1.  Get the number of chars in the string starting from the input start index.
     *  2.  If the number of chars in the string is > than the max allowable chars then
     *      substring off the first 30,000 chars into a body part.
     *      
     *      2a. Now have a string consisting of 30,000 chars but you have no idea where it
     *          cut off (it could be in the middle of a word). So you now need to get the 
     *          index of the last newline and re-break the string on that.Then insert it
     *          into the table variable and set the position.
     *
     *  3.  If the number of chars in the string IS NOT > than the max allowable chars
     *      then substring off the remaining chars into a body part and insert it into our
     *      table variable
    */
    else
    begin
        -- 1.
        select @numberOfCharactersLeftInString = (@position - @lenOfBody) * -1

        -- 2.
        if (@numberOfCharactersLeftInString > @MAX_CHARACTERS)
        begin
            select @bodyPart = substring(@body, @position, @MAX_CHARACTERS)

            -- 2a.
            select @indexToLastNewLineInBodyPart = Len(@bodyPart) - charindex(char(13)+char(10),reverse(@bodyPart))
            if (@indexToLastNewLineInBodyPart > 0)
            begin
                select @bodyPart = substring(@bodyPart,@position,@indexToLastNewLineInBodyPart)
                insert into @transcriptionBody(BodyPart) values(@bodyPart)
                select @position = @position + len(@bodyPart)
            end     
        end
        else
        begin
            select @bodyPart = substring(@body, @position, @numberOfCharactersLeftInString)
            insert into @transcriptionBody(BodyPart) values(@bodyPart)
            select @position = @position + len(@bodyPart)
        end 
    end
end
select * from @transcriptionBody order by SegmentNumber
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文