views:

351

answers:

3

Hi,

I have a large varbinary field in one of my tables, and I would like to download in parts for show a download progress indicator in my application.

How can I split the data sent in a SELECT query?

Thanks

+1  A: 

See SqlDataReader.GetBytes and CommandBehavior SequentialAccess.

It will allow you to read from a varbinary(max) with multiple calls. Then you can display progress between calls.

For ODBC see ISequentialStream (here as well), you can also read it in chunks.

Sam Saffron
A: 

I'm using ODBC with Qt4 in a C++ application. I think I need to split the data in a SELECT Statement to achieve this.

Thanks anyway.

xgoan
+1  A: 

You can do this with just the SQLGetData ODBC call. If the buffer size you provide is smaller than the total varbinary size, it will fill the buffer and return SQL_SUCCESS_WITH_INFO and and SQLSTATE 01004. If you call it again, it will return the next segment of data. You just repeat until all the data is retrieved. To know your progress as a percentage, you may be able to select the length as another column.

See here for lots of tips for getting long data.

Trevor