How to Create Reports from SQL Server Databases with List & Label to Have More Time for ...hm, Let's Say, Sweets 🍭
Tags: sqlserver, listlabel, sql, reporting
Published: 2021-09-28 15:02:58

TL;DR – Create reports based on your existing SQL databases with the reporting component _List & Label_. Easy to bind, support of relational databases, Report Designer included. Get yourself a chocolate bar and see how it works. 🍫

##How to Create Reports with List & Label Using Data from SQL Server Databases

List & Label can easily be bound to SQL server data. This allows the creation of comprehensive reports based on your existing SQL databases like viewes, tables and stored procedures. Relational databases are also supported out of the box, enabling you to drill down or drill through your data. A complete walkthrough is available in the following video (3 min).

##Generate Reports from SQL Database – Shown by Jochen


{% youtube S9-W8ll2cE8 %}

##Samples for Binding SQL Databases to List & Label
More technically, the classes involved are the [SqlConnectionDataProvider](https://www.combit.net/go?3119) to get the whole database or the [DbCommandSetDataProvider](https://www.combit.net/go?3120) to execute individual SQL commands as needed. A simple sample would be…

```// Part 1: Prepare connection information for the Microsoft SQL database
SQLConnectionStringBuilder sqlConnectionString = new SQLConnectionStringBuilder();
sqlConnectionString.DataSource = Properties.Resources.SQLServerInstanceName;
sqlConnectionString.UserID = Properties.Resources.SQLServerUsername;
sqlConnectionString.Password = Properties.Resources.SQLServerPassword;
sqlConnectionString.InitialCatalog = "Northwind";```

```// Part 2: Connect the SQL connection to the matching
// List & Label data provider for SQL connections
SqlConnection sqlConnection = new SqlConnection(sqlConnectionString.ConnectionString);
SqlConnectionDataProvider sqlDataProvider = new SqlConnectionDataProvider(sqlConnection);```

```// Part 3: Create the List & Label object and attach the SQL data provider
// and call the designer
using(ListLabel LL = new ListLabel())
{
	LL.DataSource = sqlDataProvider;
	LL.Design();
}```

… which opens the Designer automatically filled with the data from the database given in the connection string. From here, you can then proceed with one of our [Designer tutorials](https://www.combit.net/go?3121).

💡 __Tip__: The article [Using the DbCommandSetDataProvider With Stored Procedures](https://www.combit.net/go?3122) shows how easy it is to access stored procedures in an SQL database and use them as data sources for reports.

##More about SQL Reporting and List & Label
Also see the [.NET Tutorial](https://www.combit.net/go?3123) for even more valuable information on using List & Label.

It doesn’t matter if you have a classic Windows desktop application or a modern web application with ASP.NET - the List & Label [data providers](https://www.combit.net/go?3124) can be used in both worlds.

Please leave a reply to this post if you’ve got questions about how to create reports with List & Label based on data from SQL databases or if you miss any information about this topic.

If you already enjoy connecting SQL databases as datasource to List & Label for creating amazing reports, feel free to show your love with a like and take a doughnut 🍩