Delphi calls the SQL-Server2000 stored procedure

xiaoxiao2021-03-06  57

How Delphi calls the SQL stored procedure and get the result

AdoStoredProc1.Close;

AdocedProc1.ProcedureName: = 'sp_thchl';

AdoStoredProc1.Parameters.clear;

AdoStoredProc1.Parameters.createParameter ('out', ftinteger, pdoutput, 1, 1);

AdoStoredProc1.execproc;

Edit1.text: = adoStoredProc1.Parameters [0] .value;

LEFTSTR (), execute the run command system actually tells me "Unrecognizable identifier Leftstr" plus Strutils unit

The simplest database stored procedure ends CREATE PROCEDURE aaa @www varchar (10) // parameter ASselect * from employees where pusercode = @ wwwGO distal stored procedure procedure TForm1.Button1Click (Sender: TObject); var outcount: integer; begin ADOStoredProc1. Parameters.Parambyname ('@ www'). Value: = '00001'; adoStoredProc1.Open; //adostoredproc1.execproc; // {hypothesis you already have a storage process in the SQL server, then you need one AdoConnection Settings Database Connections, AdoStoreProc's Connection Connection Adoconnection After PRODUCEDURE will automatically appear in the existing stored procedure to set up the connection, you can see all the calling procedures that can be called in the AdoCedProc ProcedureName, choose to use it. The storage process (by parameter can see the parameters it needs) program call code: with adostoreproc1 dobegin adoRedProc1.Parameters.Parambyname (''). Value: =; adoStoredProc1.execProc; END; above is the storage process does not return The use of the result set, if there is a return result set, use adostoredProc1.open to open} // showMessage (INTOSTOREDPROC1.Parameters.Parambyname); END;

Stored procedure with output parameters

CREATE PROCEDURE aaa @abc char (10), @ mycount int outputASselect @ mycount = count (*) from employees where pusercode = @ abcreturnGO how parameter extraction procedure TFrm_worker_info.Button1Click (Sender: TObject); var outcount: integer; begin ADOStoredProc1.Parameters .Parambyname ('@ ABC'). Value: = '00001'; adoStoredProc1.execproc; showMessage (INTOSTOREDPROC1.Parameters.Parambyname);

转载请注明原文地址:https://www.9cbs.com/read-82232.html

New Post(0)