Page 1 of 1

Very large posts

Posted: Sat 24 Nov 2007 00:32
by laegteskov
I'm developing an application in which files could be stored in the SQL-database tables and that raised the question if the user could get feedback when he transfers a huge file (>20mb) over e.g. a 2048/512 kbit line to a record in the table.

Is this possible in any way? Could chunks be transfered to the SQL-server so it could be shown on a percentagebar or something like that?

I don't know if this approach:
Table.FieldByName('Content').AsString:=FileContent;
or creating a SQL-statement with the MSSQL-component is a way.

Thanks in advance,

Lasse Laegteskov

Posted: Mon 26 Nov 2007 09:14
by Antaeus
There is no possibility in SDAC to make a progress bar for posting values of a big size.
You can try to show an animation instead of the progress bar.

Posted: Mon 26 Nov 2007 10:12
by laegteskov
I wasn't sure if this was something that should be done by SDAC (if possible) or by some other way. I think I found a solution to the problem:

I could create a large dummy value and insert it into the field like in this code I found on the net:

Code: Select all

set nocount on
create table demo (ID int identity, LargeString varchar(max))
insert into demo (LargeString) values ( 'abc' + replicate(cast('d' as varchar(max)), 10000) + 'efg')
select ID, len(LargeString) Length from demo
drop table demo
where 10000 is the filesize and then use the .WRITE operation in UPDATE-queries:

Code: Select all

.WRITE ( expression, @Offset , @Length )
to write chunks into the field.

It's all in theory right now - I haven't tested it yet.

Thank you for the answer (and I guess the MySQL answer is for another forum?)

Posted: Tue 27 Nov 2007 07:52
by Antaeus
I checked your solution with Management Studio, and it works fine. I modified your example in this way:

Code: Select all

SET NOCOUNT ON
CREATE TABLE demo (ID INT IDENTITY, LargeString VARCHAR(MAX))
INSERT INTO demo (LargeString) VALUES ( 'abc' + REPLICATE(CAST('d' as VARCHAR(MAX)), 10) + 'efg')
SELECT LargeString, ID, len(LargeString) Length FROM demo
UPDATE demo set LargeString .WRITE('1234567890', 16 , 10)
SELECT LargeString, ID, len(LargeString) Length FROM demo
UPDATE demo SET LargeString .WRITE('1234567890', 26 , 10)
SELECT LargeString, ID, len(LargeString) Length FROM demo
DROP TABLE demo
Note, this approach may decrease performace of your application.