Code covered by the BSD License  

Highlights from
Myblob

Myblob

by

 

07 Jan 2006 (Updated )

Exchange blobs (binary large objects) with MySQL databases

myblob_command (ado_connection, command)
function cell_array = myblob_command (ado_connection, command)
%MYBLOB_COMMAND  Send an SQL statement to a MySQL database
% 
%   CELL_ARRAY = MYBLOB_COMMAND (CONNECTION, COMMAND)
%       sends the SQL statement string COMMAND to the MySQL database. 
%       CONNECTION is the handle to the ADODB connection object;
%       it is returned by a previous call to MYBLOB_OPEN. 
%       Results from a SELECT statement are returned in CELL_ARRAY.
%   
%   Examples: 
%       myblob_demo
%   
%   See also: myblob_demo, myblob_open, myblob_from_db, myblob_to_db, myblob_close.

%   Joerg J. Buchholz, Hochschule Bremen, buchholz@hs-bremen.de
%
%   Version 1.0 (2006-01-07)

% Instantiate ADO command object
ado_command = actxserver ('ADODB.Command');

% Communicate the sql command string to the command object
ado_command.CommandText = command;

% Communicate the connection object to the command object
ado_command.ActiveConnection = ado_connection;

% Instantiate ADO record set object
ado_recordset = actxserver ('ADODB.Recordset');

% Communicate the command object to the record set object
% and open the record set object
ado_recordset.Open (ado_command);

% Suppress output if anything goes wrong 
% (empty record set, closed record set , ...) 
try

    % Read the whole table (including blobs) into one big cell array
    cell_array = ado_recordset.GetRows;
    
    % Close record set object
    ado_recordset.Close;

catch
    
    % If anything went wrong return an empty set
    cell_array = [];
    
end

Contact us