BLOBs (SAP HANA Data Provider for Microsoft ADO.NET)

When fetching long string values or binary data, there are methods that you can use to fetch the data in pieces. For binary data, use the GetBytes method, and for string data, use the GetChars method.

Otherwise, BLOB data is treated in the same manner as any other data you fetch from the SAP HANA database server.

Microsoft C# GetChars BLOB Example

This example reads three columns from a result set. The first two columns are integers, while the third column is a CLOB. The length of the third column is computed by reading this column with the GetChars method in chunks of 100 characters.

HanaConnection conn = new HanaConnection( 
    "server=<hana-server:port>;UserID=<uid>;password=<pwd>" );
conn.Open();
HanaCommand cmd = new HanaCommand(
    "SELECT * FROM DEMO.MarketingInformation", conn);
HanaDataReader reader = cmd.ExecuteReader();

int idValue;
int productIdValue;
int length = 100;
char[] buf = new char[length];
while (reader.Read())
{
    idValue = reader.GetInt32(0);
    productIdValue = reader.GetInt32(1);
    long blobLength = 0;
    long charsRead;
    while ((charsRead = reader.GetChars(2, blobLength, buf, 0, length))
            == (long)length)
    {
        blobLength += charsRead;
    }
    blobLength += charsRead;
}
reader.Close();
conn.Close();