GetUniBlob(String) Method
Gets the value of the specified column as a
UniBlob object.
'Declaration
Public Overloads Function GetUniBlob( _
ByVal As String _
) As UniBlob
Parameters
- name
- The name of the column to get value of.
Return Value
The value of the specified column as a
UniBlob object.
This example shows how to download a BLOB field from a table using
GetUniBlob method.
public void DownloadBlob(UniConnection myConnection)
{
UniCommand myCommand = new UniCommand("SELECT * FROM Test.Pictures", myConnection);
myConnection.Open();
UniDataReader myReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default);
try
{
while (myReader.Read())
{
UniBlob myBlob = myReader.GetUniBlob(myReader.GetOrdinal("Picture"));
if(!myBlob.IsNull)
{
string FN = myReader.GetString(myReader.GetOrdinal("PicName"));
FileStream fs = new FileStream("D:\\Tmp\\"+FN+".bmp", FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
w.Write(myBlob.Value);
w.Close();
fs.Close();
Console.WriteLine(FN+" downloaded.");
}
}
}
finally
{
myReader.Close();
myConnection.Close();
}
}
Public Sub DownloadBlob(ByVal myConnection As UniConnection)
Dim myCommand As New UniCommand("SELECT * FROM Test.Pictures", myConnection)
myConnection.Open()
Dim myReader As UniDataReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default)
Try
While myReader.Read()
Dim myBlob As UniBlob = myReader.GetUniBlob(myReader.GetOrdinal("Picture"))
If Not myBlob.IsNull Then
Dim FN As String = myReader.GetString(myReader.GetOrdinal("PicName"))
Dim fs As FileStream = New FileStream("D:\Tmp\" + FN + ".bmp", FileMode.Create)
Dim w As BinaryWriter = New BinaryWriter(fs)
w.Write(myBlob.Value)
w.Close()
fs.Close()
Console.WriteLine(String.Concat(FN, " downloaded."))
End If
End While
Finally
myReader.Close()
myConnection.Close()
End Try
End Sub