logo
small logo
  • Produkty
  • Zamów
  • Wsparcie techniczne
  • About
  • Customer panel Wsparcie techniczne
    • en
    • de
    • JP
    • ZH
  • Glówna strona
  • /
  • Articles
  • /
  • How to use stored procedures in FastReport.Net
  • Jak wybrać najwyższe wartości w macierzy?

    22 kwietnia 2021

    Artykuł jest aktualny do wersji 2022.1. FastReport .NET posiada świetne narzędzie do wyświetlania danych w postaci

    read more
  • Jak połączyć się z bazą danych Sybase SQL Anywhere

    29 lutego 2020

    Baza danych Sybase SQL Anywhere ma szereg przydatnych funkcji, które sprawiają, że bardzo się wyróżnia

    read more
  • Raportowanie z PostgreSQL w aplikacji .NET 5 dla Debian 10

    25 maja 2022

    Z pewnością wielu potrzebuje rozwiązania, które będzie generować raporty dla systemów Linux, a także wspierać

    read more
  • Budowanie biblioteki libgdiplus ze źródła

    2 października 2020

    Korzystając z bibliotek FastReport.NET (Core), FastReport Open Source i FastReport Mono w systemie operacyjnym Linux,

    read more
  • Tworzenie i wyprowadzanie kodów kreskowych ITF-14 w aplikacjach .NET

    25 lutego 2021

    ITF-14 (Interleaved Two of Five) to dwupasmowy kod numeryczny, znany również jako kod o

    read more

How to use stored procedures in FastReport.Net

14 sierpnia 2018

In this article we will discuss the use of stored procedures to retrieve data for a report. Using the MS SQL example, I'll show you how to create and use functions in a report.

As you know, Transact SQL allows us to create stored procedures and functions. Stored procedures are used to automate any action. The functions are intended to expand the capabilities of queries. They can be executed as part of a query and always return a value. Stored procedures are called  by execute instructions and cannot return any values.

To retrieve data in a report, you can use both a stored procedure and a function.

But the topic of this article is the use of stored procedures.

For example, here is the simplest stored procedure, which will return the list of employees by the unit name:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
SET ANSI_NULLS ON
 
GO
 
SET QUOTED_IDENTIFIER ON
 
GO
 
-- =============================================
 
-- Description: Returns employees by department
 
-- =============================================
 
ALTER PROCEDURE dbo.DepartmentEmployee
 
 @DepName varchar(20)
 
AS
 
BEGIN
 
SELECT em.*, dep.NAME FROM dbo.DEPARTMENT dep
 
JOIN dbo.EMPLOYEE em ON em.DEPT_ID = dep.DEPT_ID
 
WHERE dep.NAME = @DepName
 
END
 
GO

 And now we use this stored procedure in the report. Create a connection to the MS SQL database:

 

At the stage of selecting tables, press the button:

 

The Create Query Wizard starts. In the first step, you need to specify the name of the new table, we proceed further.

 

Enter the text of the SQL query. We will send the report parameter as the value of the query parameter.

In the next step, create the @Dep parameter.

In the Expression property, specify the report parameter.

The value of the report parameter can be specified in the Expression property:

 

You can also set the value of the parameter in the dialog form before the report is displayed.

We transfer the fields from the data source in the data window to the data band. Run the report:

 

As you can see, all employee records for the "Operations" department are displayed.

about product zamów
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport SQL

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Zamów
  • Pobierz
  • Dokumentacja
  • Opinie użytkowników
  • Jak odinstalować nasze produkty
  • FAQ
  • Tutorial Video
  • Forum
  • Support SLA
  • Articles
  • Our News
  • Prasa o nas
  • Partnerzy
  • Extended licensing
  • Kontakty

© 1998-2023 by Fast Reports Inc.

  • Poufność

Trustpilot