Please enable JavaScript to view this site.

Navigation: » No topics above this level «

Data Access Layer

Scroll Prev Next More

 

Deprecated

Data Access Layer (DAL) is deprecated. While the existing code keeps working, we recommend switching to Database API.

 

Each table in DAL is presented as a ASP class, all fields are ASP variables declared in this class.

Variables/Arrays

Variable/Array

Description

Table("TableName")

Provides access to the TableName.

 

Example:

 

dal.Table("Cars")

 

Value("FieldName")

Provides access to the field values to be updated or added.

 

Example:

 

dal.Table("Cars").Value("Make")

 

Param("FieldName")

Provides access to the field values. This function is used in the WHERE clause of the update query. This allows you to avoid the confusion when the same field appears in the field list and in WHERE clause.

 

Example:

 

dal.Table("UsersTable").Param("FirstName")="Bob"
dal.Table("UsersTable").Value("FirstName")="Jim"
dal.Table("UsersTable").Update()

 

The corresponding SQL query:

 

Update UsersTable set 'FirstName'='Jim' where 'FirstName'='Bob'

 

Methods

Method

Description

Add()

Inserts a new record into the database.

CustomQuery()

Runs a custom SQL query.

Delete()

Deletes one or more records from the database.

DBLookup()

Executes an SQL query passed as a parameter and returns the first value of the first entry or null if nothing is found.

FetchByID()

Selects one or more records matching the condition.

Query()

Selects records from database and sorts the data by orderby field/fields and returns the recordset.

QueryAll()

Selects all records.

TableName()

Returns the table name. This function is used for complex queries with calculated fields or joined tables.

Update()

Updates one or more records in the database.

UsersTableName()

Returns a properly formatted login table name.

whereAdd()

Adds a new AND condition to the existing WHERE clause.

Examples

Before deleting a record check if related records exist

Dynamic SQL Query

Redirect to user info edit page

Show data from master table on details view/edit/add page

Show list of customer orders

Update multiple records on the List page

Update multiple tables

See also:

Database API

Using DAL functions in projects with multiple database connections

Connecting to the database

Datasource tables screen