TMSStoredProc

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
quinze
Posts: 2
Joined: Fri 06 Apr 2007 19:17

TMSStoredProc

Post by quinze » Wed 20 May 2009 20:20

Can someone please tell me how to pass input parameters to a stored procedure using TMSStoredProc?

If I use proc->ParamByName I'm told the parameter doesn't exist.
If I use proc->Params->CreateParam, as with BDE, I get OLE DB errors saying invalid param type.

Thanks in advance.

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 21 May 2009 09:35

To solve the problem you should call the TMSStoredProc.PrepareSQL method before setting parameter values.

quinze
Posts: 2
Joined: Fri 06 Apr 2007 19:17

Post by quinze » Fri 22 May 2009 08:05

Thank you.

jerry_oei
Posts: 1
Joined: Thu 02 Dec 2010 04:16

ERROR using TMSSTOREDPROC

Post by jerry_oei » Thu 02 Dec 2010 04:26

Each time i execute storedproc i always got error message "Parameter not found kode_barang "...
can u help me???
this is my code below ..
======================

with dm.adoCmd do
begin
StoredProcName:='NEW_MASTER_BARANG;1(:KODE_BARANG, :NAMA_BARANG, :SATUAN, :KATEGORI, :BRAND, :TIPE, :MINIMUM_STOK, :PLOT)';
PrepareSQL;
with Params do
begin
ParamValues['KODE_BARANG']:=editKodeBarang.Text;
ParamValues['NAMA_BARANG']:=editNamaBarang.Text;
ParamValues['SATUAN']:=editsatuan.Text;
ParamValues['KATEGORI']:=editKategori.Text;
ParamValues['BRAND']:=editBrand.Text;
ParamValues['TIPE']:=editTipe.Text;
ParamValues['MINIMUM_STOK']:=strtoint(editMinimunStok.Text);
ParamValues['PLOT']:='1';
end;
Execute;
end;

bork
Devart Team
Posts: 648
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 02 Dec 2010 08:57

Hello

Please try the following code:

Code: Select all

begin
  MSConnection1.Open;

  try
    MSConnection1.ExecSQL('DROP PROCEDURE NEW_MASTER_BARANG2', []);
  except
  end;

  try
    MSConnection1.ExecSQL('CREATE PROCEDURE NEW_MASTER_BARANG2 ' + #13 +
                          '  @KODE_BARANG varchar , ' + #13 +
                          '  @NAMA_BARANG varchar , ' + #13 +
                          '  @SATUAN varchar , ' + #13 +
                          '  @KATEGORI varchar , ' + #13 +
                          '  @BRAND varchar , ' + #13 +
                          '  @TIPE varchar , ' + #13 +
                          '  @MINIMUM_STOK int , ' + #13 +
                          '  @PLOT varchar ' + #13 +
                          'AS ' + #13 +
                          'BEGIN ' + #13 +
                          '  SET NOCOUNT ON ' + #13 +
                          'END', []);
  except
  end;

  with MSStoredProc1 do
  begin
    StoredProcName:='NEW_MASTER_BARANG2'; // StoredProcName:='NEW_MASTER_BARANG2;1'; also work correctly
    PrepareSQL;
    with Params do
    begin
      ParamValues['KODE_BARANG']:='1';
      ParamValues['NAMA_BARANG']:='1';
      ParamValues['SATUAN']:='1';
      ParamValues['KATEGORI']:='1';
      ParamValues['BRAND']:='1';
      ParamValues['TIPE']:='1';
      ParamValues['MINIMUM_STOK']:=strtoint('1');
      ParamValues['PLOT']:='1';
  end;
    Execute;
  end;
end;

Post Reply