Delphi calls stored Procedures

Source: Internet
Author: User

1. The table structure is as follows (budget data schedule):

CREATE TABLE [dbo]. [Ba_feedetail] (
[ID] [int] IDENTITY (*) Not NULL,
[Feedeptid] [nvarchar] (4) NULL,
[Feedate] [INT] Null
[Feecode] [nvarchar] (Ten) NULL,
[Feetype] [nvarchar] (1) NULL,
[Batype] [nvarchar] (1) NULL,
[Feeamt] [Float] Null
) on [PRIMARY]

2. Create a stored procedure (used to obtain a budget for a certain department for a certain amount of the budget)

CREATE PROCEDURE [dbo]. [Getbudgetamt]
--Add The parameters for the stored procedure here
@DeptID nvarchar (4) = ' 7120 ',
@FeeDate int = 201301,
@FeeCode nvarchar (8) = ' 31301 ',
@FeeType nvarchar (1) = ' 2 ',
@BAType nvarchar (1) = ' 1 ',
@FeeAmt Float output
As
BEGIN
--SET NOCOUNT on added to prevent extra result sets from
--interfering with SELECT statements.
SET NOCOUNT on;

--Insert statements for procedure here
SELECT @FeeAmt = Feeamt from Ba_feedetail where (
Feecode = @FeeCode and
Feetype = @FeeType and
Feedate = @FeeDate and
Feedeptid = @DeptID and
Batype = @BAType
)

Return @FeeAmt
END

Calls in 3.delphi programs (using Adoconnect and Adostoreproc)

Procedure Tform1.btn1click (Sender:tobject);
Var
Budgetamt:single;
Begin
With ADOSP1 do
Begin
ProcedureName: = ' Getbudgetamt ';
parameters.refresh;//must have this statement, refresh the parameters
Parameters.parambyname (' @DeptID '). Value:=edtdept.text;
Parameters.parambyname (' @FeeDate '). Value:=edtfeedate.text;
Parameters.parambyname (' @FeeCode '). Value:=edtfeecode.text;
Parameters.parambyname (' @FeeType '). Value:=edtfeetype.text;
Parameters.parambyname (' @BAType '). Value:=edtbatype.text;
Parameters.parambyname (' @FeeAmt '). value:=0.00;
Execproc;
Budgetamt:=parameters.parambyname (' @FeeAmt '). Value;
Edtfeeamt.text:=format ('%.2f ', [Budgetamt]);
End
End

Delphi calls stored Procedures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.