using result set of an SP in Delphi code

using result set of an SP in Delphi code

Postby Chagh » Mon 22 Aug 2005 12:48

hi all,
would you please put an example in Delphi wich takes a result set from a MySQL stored procedure(which has got a select in it) ?
and another one which uses OUT parameter of an SP?
i've installed mysqldirect but i can not use it properly.

Thanks in advance
Chagh
Chagh
 
Posts: 2
Joined: Mon 22 Aug 2005 12:36

Postby Serious » Tue 23 Aug 2005 14:16

Here ia an example in Delphi wich takes a result set from a MySQL stored procedure called "MR".
Code: Select all
procedure TWinForm.Button2_Click(sender: System.Object; e: System.EventArgs);
var
  connection: MySqlConnection;
  command: MySqlCommand;
  dataAdapter: MySqlDataAdapter;
  ds: DataSet;
begin
  connection := MySqlConnection.Create('host=server;port=3308;database=test;user id=root;password=root;');
  command := MySqlCommand.Create('MR', connection);
  command.CommandType := CommandType.StoredProcedure;
  dataAdapter := MySqlDataAdapter.Create(command);
  ds := DataSet.Create();
  connection.Open();
  try
    dataAdapter.Fill(ds);
    DataGrid1.DataSource := ds;
  finally
    connection.Close();
  end;
end;
Code: Select all
CREATE PROCEDURE test.MR()
BEGIN
  select * from emp;
  select * from dept;
END;
MySql protocol does not supports returning OUT parameters to client side. You can use them only at server side.
Serious
 


Return to dotConnect for MySQL