Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

In this lesson we are going to review Wayfast Datasets. A dataset allows us to connect a page with a data source like a database or an API. To depict how it works we will show you and example that include calling a database store procedure for retrieving information and displaying it in a Wayfast Application.    

Preconditions

We have 2 3 important preconditions before start working with Datasets.

  1. We need to connect the project with an existing or new database. You can find more details about in another lessons where we attached or created databases.

  2. We need to create a table or identify the table where we are going to get the data to display using the Dataset

  3. We need to create an object in this database, for example, an Stored Procedure to link the table and interact with Dataset information.

Code Block
languagesql
CREATE PROCEDURETABLE spHola_Mundo_AccionesTest_Insert
  @Data1 HWD_Roles (
Name  nvarchar(50),
Role  @Data2nvarchar(50),
Email nvarchar(50),
)
GO

CREATE PROCEDURE spHWD_Roles_Get
AS
  BEGIN
    INSERT Hola_Mundo_AccionesTest(Data1,Data2)
	SELECT @Data1, @Data2SELECT * FROM HWD_Roles with(nolock)
  END
GO
Stored Procedure will have 2 parameters named as @data1 and @data2. Let’s execute the query to create the object in the database.

Now we can go back to Wayfast and synchronize the stored procedure in the environment. If the project is newly created and connected to a database, there’s no need to synchronize both objects. Dataset will retrieve all the objects associated between both entities automatically.

...

A popup is displayed, click on “Synchronize” button. Now the stored procedure created in database will be available to connect with dataset.

How to create a new Dataset?

Go to “Project Pages” at top menu. Select any of the pages available in the project. Then click on “New Dataset” button

...

This is how it looks like:

...

How to connect the new Dataset with a “Grid Column” control?

Let’s create an example using grid columns linked to the new dataset.

...

Info

If page has multiple grid columns to reassign, we can use “Massive Mod” button which is a feature to easily make the bulk change.

...

Recap

We learnt about the importance of Datasets to interact with database and how the Store Procedure is needed for this purpose. We explained how some type of controls are specifically created to show the information from the Dataset to make it available at the moment we open the page.