Use the GetChars method to issue a command that returns a string.
For C#:
AseCommand cmd = new AseCommand( "select au_id, copy from blurbs", conn );
For Visual Basic .NET:
Dim cmd As New AseCommand( _ "select au_id, copy from blurbs", conn)
For C#:
AseDataReader reader = cmd.ExecuteReader();
For Visual Basic .NET:
Dim reader As AseDataReader = cmd.ExecuteReader()
The following code reads the two columns from the result set. The first column is a varchar, while the second column is Text. GetChars is used to read 100 characters at a time from the Text column:
For C#:
int length = 100;
char[] buf = new char[ length ];
String au_id;
long dataIndex = 0;
long charsRead = 0;
long blobLength = 0;
while( reader.Read() )
{
au_id = reader.GetString(0);
do
{
charsRead = reader.GetChars(
1, dataIndex, buf, 0, length);
dataIndex += length;
// do something with the chars read
//.... some code
//
// reinitialize char array
buf = new char[ length ];
} while ( charsRead == length );
blobLength = dataIndex + charsRead;
}
For Visual Basic .NET:
Dim length As Integer = 100 Dim buf(length) As Char Dim au_id As String Dim dataIndex As Long = 0 Dim charsRead As Long = 0 Dim blobLength As Long = 0 While reader.Read() au_id = reader.GetString(0) Do charsRead = reader.GetChars( _ 1, dataIndex, buf, 0, length) dataIndex = dataIndex + length ' do something with the data read ' ' use code ' ' reinitialize the char array ReDim buf(length) Loop While (charsRead = length) blobLength = dataIndex + charsRead End While
For C#:
reader.Close(); conn.Close();
For Visual Basic .NET:
reader.Close() conn.Close()