Liquid UI - Documentation - 4.4.2 Running, Accessing, and Displaying ODBC Data in Web Server

4.4.2 Running, Accessing, and Displaying ODBC Data in Web Server


Running ODBC

To run the ODBC functionality via Web Server, first ensure that all the necessary files are in the correct locations and that Web Server is itself running. Once this is done, please follow the steps below to start the ODBC

  1. Open a command prompt.

  2. Type in the following command string.

    C:\> GuiXT4WebApp.exe -f test.js
    Note: The 'test.js' is a sample configuration file as previously introduced. We will discuss it in more detail in the following sections.
  3. The application wil now launch and you can begin to access databases and mainpulate data.

Accessing a Database

To access a ODBC-compliant database, please do the following.

  1. Open the 'test.js' file that we introduced earlier. In the this file, enter the following code.

    load('wsodbc.dll');
  2. The wsodbc libraries are now available for use. Enter the following line in the test.js file.

    a = new odbc('Driver={SQL Native Client}; Server = {<server_name>}; Database = {testdb}; Trusted_Connection=Yes');

    This code creates a new database object 'a' and assigns it the relevant parameters. Once created, this object can be used repeatedly in your scripts. The parameters are defined as follows.

    • Driver: Defines the driver. Use the default entry shown in the above example - 'SQL Native Client'
    • Server: Defines the name of the SQL server you are connecting to. Input the actual name of the target SQL server.
    • Database: Defines the name of the database. Input the actual name of the target database.
    • Trusted_Connection: Specifies if the connection is or is not a trusted connection. Make sure this setting is 'Yes' as in the above example.

Displaying Data

Once we have loaded the ODBC application and created a connection to the database, we can proceed to retrieve and display data from the database tables. To execute queries and display data, we will use the wsodbc object 'a' we had previously created. This object has methods and properties attached, just as all Javascript objects do. One of these methods is the 'select' method. We will use this method to execute a simple query, writing the SQL query inside the function as shown below:

  1. A query for moving objects from an SQL database is called a drop query. An example of a drop query used with wsodbc is shown below.

    a.exec('drop table table1');

  2. You can also use a for loop to return and print our all relevant records that match a specified list of parameters, as shown in the following example.

    for record <- a.select=""
      for="" (name="" in="" record=""
      {
        print(name=""+':'+record=''[name='']+' ');
      }  
    }
  3.  


Executing SQL Queries

 

  1.  


  2.  


  3.  



Can't find the answers you're looking for?