
Programming i!-Database Plus
9
i!-Database Plus and DBWizard
Creating an ASP file
All you need to do in your ASP file is include the NetLinxDBInclude.asp file, and call a single
function,
RunDBQuery
. There are only two lines of code:
<!-- #INCLUDE FILE="NetlinxDBInclude.asp" -->
<% RunDBQuery "DeluxeCD.mdb", "" %>
The first parameter is the name of a Microsoft Access database. The second parameter is used for
advanced applications and normally should be an empty string. The
RunDBQuery
function will
take care of making the connection to the database and returning all the records to the NetLinx
system. If you want to use a DSN entry instead of a Microsoft Access database, simply include the
DSN= and the DSN entry name. The following syntax connects to a database setup using the DSN
entry MyDSNEntry:
<!-- #INCLUDE FILE="NetlinxDBInclude.asp" -->
<% RunDBQuery "DSN=MyDsnEntry", "" %>
For more information about setting up a data source name (DSN), see the
Data Source
Name
section on page 5.
Creating an AXI file
Now that the ASP file is complete, it's time to program the NetLinx AXI file. You need to include
NetlinxDBInclude.axi
in order to provide access to the support functions that make your job much
easier. In the process of writing the AXI file, you will need to generate SQL statements to access
the database. If you are not familiar with SQL, you have a couple of options. You can learn SQL,
use Microsoft Access to generate SQL statements for you, or use DBWizard to help generate the
SQL statements and the NetLinx code. The DBWizard option is the easiest and fastest way to
integrate to the database. To learn more about SQL, return to the
Structure Query Language
(SQL)
section on page 5.
The first part of the AXI file includes the NetlinxDBInclude.axi file and defines an IP device
number for the connection to the web server:
#INCLUDE 'NetlinxDBInclude.axi'
(***********************************************************)
(* DEVICE NUMBER DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_DEVICE
dvDB_CLIENT = 0:3:0
The next section creates NetLinx Data structures that will be used to hold the data returned from the
database. These structures closely match the column names and data types that are defined in the
database. This structure represents the titles table and contains information about each CD in the
database:
Continued