Apologies for the lack of detail. The problem is apparent because
when selecting the longtext feild, using READTEXT as below, the text
data cuts off after 255. The problem could be here, getting data out -
I'm not convinced I have the code right, I just think it's in the
getting data in.
Thanks very much for your help, let me know if you need different
info,
Iain
Code samples:
To get data out from the longtext column(content) by id:
javascript:
try {
conn.Open(strConn);
cmd.ActiveConnection = conn;
cmd.CommandText = "SelectContent";
cmd.CommandType = adCmdStoredProc;
cmd.Parameters.Append(cmd.CreateParameter("@id", adInteger,
adParamInput, 4, id));
contentRS = cmd.Execute();
var content = "";
while (!contentRS.EOF) {
content += contentRS("content");
contentRS.MoveNext;
}
}
....
return content;
SQL (SelectContent):
SET NOCOUNT ON
DECLARE
@txtptrval VARBINARY(16),
@startOffset INT,
@readLength INT,
@datalength INT
SELECT @txtptrval = TEXTPTR(content) FROM papers WHERE id=@id
SELECT @startOffset = 0
SELECT @readLength = 255
SELECT @datalength = DATALENGTH(content) FROM papers WHERE id=@id
-- If last chunk, reduce buffer size to the nChars remaining
IF ((@startOffset + @readLength) > @datalength) (
SELECT @readLength = @datalength - @startOffset
)
WHILE (@startOffset < @datalength)
BEGIN
READTEXT papers.content @txtptrval @startOffset @readLength
SELECT @startOffset = @startOffset + @readLength
-- Last chunk, reduce buffer size to the get the last nChars
remaining
IF (@startOffset + @readLength) > @datalength
SELECT @readLength = @datalength - @startOffset
END
SET NOCOUNT OFF
END
---------------------------------------------------------------------
To get data in:
CREATE proc InsertPaper
@authors nvarchar(20),
@title nvarchar(255),
@pubyear int,
@journal nvarchar(255),
@issue int,
@pages nvarchar (13),
@paperabstract text,
@content text,
@id int OUTPUT
as
insert into Papers(authors, title, pubyear, journal, issue, pages,
abstract, content)
values (@authors, @title, @pubyear, @journal, @issue, @pages,
@paperabstract, @content)
select @id = @@identity
GO
--------------------------------------------------------