2008-12-23 103 views
1

我最近解决了一个问题,我的VB6应用程序使用ADO 2.8和AppendChunck方法将Recordset.Field保存为大型二进制对象。如果数据太大,我会在for循环中得到'Invalid Handle'或'没有足够的系统存储来执行此操作'。我通过发送块到存储过程并使用'updatetext'来解决这个问题。但是,在这样做的情况下,由于8k的限制,我现在只能一次发送8k个字符。有人知道一个很好的解决方法吗?以下是我的sproc。解决sql服务器存储过程参数8k限制

@chunck binary(8000), 
@result_id int 

as 

declare @pointer binary(16), 
     @imagelength int, 
     @datalength int 


--get the pointer and length to the image column  
select @pointer = textptr(result_image), 
     @imagelength = datalength(result_image) 
from dbo.dash_result 
where result_id = @result_id 

if @pointer is null 

update dbo.dash_result 
set result_image = @chunck 
where result_id = @result_id 

else 

begin 

    --append the chunck of data to the end 
    set @datalength = datalength(@chunck) 
    updatetext dbo.dash_result.result_image @pointer @imagelength 0 @chunck 

end 

回答

0

对于sql server 2000,将参数声明为文本。请注意,它必须是一个参数,而不是一个本地变量,只有参数可以是文本,而不是本地变量。

+0

工作,但我不得不使用图像,而不是文字。 – 2008-12-23 16:02:31

2

如果您使用的是SQL Server 2005中,你可以使用VARBINARY(MAX)数据类型或VARCHAR(MAX)数据类型,取决于数据要存储类型。我相信这些可以容纳2 Gig的数据。