398 users using DBSP now!
home -> documentation -> language reference -> alias property


Description

Mandatory on the DATASET and QRYEXEC elements, the ALIAS property refers to the database connection that will be used when executing a certain SQL sentence. This connection alias was previously defined using the DBSP Configuration tool.


Syntax

<#DATASET ALIAS="AliasName" QUERYID="NumberQuery">

<#/DATASET>

or

<#QRYEXEC ALIAS="AliasName" QUERYID="Id">

 

Applications

This property is always used for operations that involve database access. Each alias should reference a unique database although you could have two or more different aliases referencing the same database. However, you can not have the same alias name for two or more different databases.

The ALIAS property is mandatory in DBSP tags:

DATASET
QRYEXEC

Examples

Example 1. Using alias with DATASET Tag.

The following example shows how to display the data obtained with a simple SELECT statement using a DATASET tag.

Source code


 
  
     <br>      dataset example <br>    
       
    
  
  
  

reading data from a table


   
 
  
    
     
          
  

     this example illustrate the usage of the dataset element and how the queryid identifier is linked to a sql statement. in addition, the example shows how the data is displayed inside a dbsp page.
      

  
  
          
     
                    
        <#dataset alias=dbspdemo queryid=1>
       
        
                                        
              
        <#/dataset>      
           
    
     
       

         company 
        
        

         contact name 
                                        
       

         <#companyname/> 
        

         <#contactname/> 
        
   
       


Test example


Example 2. Using QRYEXEC Tag.

This example shows how to update records using a web page.

Source code

OperativeExamples/QryExec/Update.dbsp

 
  
     <br>      dataset example <br>    
    
    
    
    
 
    
    
                   
  
   
  
 
  
  

update a record


   
 
  
  
   
        
  

       this example shows you a dataset containing all the dbsp_users table records. to update a record you can add a simple input form to the page, and execute an update command in the form submit event handler. the update button shows a page where you can update the selected record.          
    

  
      
     
         
     
                 
        
        
        
                                                                               
                   
        <#dataset alias=dbspdemo queryid=19>      
       
                 
        
        
                                        
                                                                               
       
       <#nodata>
      
        
                   
        <#/dataset>      
           
    
     
       
 
         first name 
        

         last name 
        

         username 
        

         password 
        
 
            
          

         <#firstname/> 
        

         <#lastname/> 
        

         <#usrname/> 
        

         <#usrpassword/> 
        

         there are no users registered.
        

   

   
      
    
     
   
          
     
   
     
   
                   
     

   
      
  


OperativeExamples/QryExec/UpdateExec.dbsp

 
  
     <br>      dataset example <br>    
    
    
        
                    
  
   
                      
  
  

update a record


   
  
    
     
          
  

         just edit the user information. once you have finished press accept to update the record.     
      

  
  
   
  
     
   <#dataset alias=dbspdemo queryid=15>  
       
       
            
            
                
            
            
            
                
            
            
            
                
            
            
            
          
                           
    
     
          
first name*  
              
            
last name*  
              
            
username*  
              
            
password*  
              
            

   <#/dataset>   
   

   
      
    
     
   
        
     
   
     
                       
        
     

   
      
  


Test example