AMX DBWizard Instruction Manual Download Page 17

Programming i!-Database Plus

13

i!-Database Plus and DBWizard

need to fill this out properly. See the section

Putting It All Together

section on page 28 for 

reference. Also, call 

DB_LISTBOX_INIT

 to initialize your listbox.

(***********************************************************)

(*                STARTUP CODE GOES BELOW                  *)

(***********************************************************)

DEFINE_START

(* INIT dB WEB CLIENT *)

DB_INIT_CLIENT (sDB_CLIENT,dvDB_CLIENT,'192.168.12.175',80,'/dB/CDExample.asp')

CREATE_BUFFER dvDB_CLIENT,sDB_CLIENT.strBUFF

(***********************************************************)

(*                STARTUP CODE GOES BELOW                  *)

(***********************************************************)

DEFINE_START

DB_LISTBOX_INIT(sTitleListBox,10,1)

The next section of code reads the information from the web server and copies the data to the 

structure you created to hold the results. The 

DATA_EVENT

 below has a couple of different parts.

The 

ONERROR

 section of the 

DATA_EVENT

 occurs whenever we encounter a communications 

problem. The code here simply clears the buffer, calls 

DB_GET_IP_ERROR

 to return a text error 

from our error code (held by 

DATA.NUMBER

) and prints the error to the terminal.

The 

ONLINE

 section of the 

DATA_EVENT

 occurs whenever a connection to the web server is 

established. The code here clears our buffer and calls 

DB_BUILD_HTTP_GET

 to format the request 

for the web server. Send this request to the server and it will process the results and return the 

information.

The 

OFFLINE

 section of the 

DATA_EVENT

 occurs whenever a connection to the web server is 

dropped. A web server will normally drop the connection whenever is has finished processing the 

request, so this is a great time for to interpret the results received. Normally, this would occur in a 

STRING

 section of a 

DATA_EVENT

. The first thing to do is create a series of variables that needed 

through the event. To kick off the processing, call 

DB_PROCESS_HTTP_HEADER

 which will parse 

the HTTP header information from the response and deal with any cookies the web server wants 

you to deal with. Once that has happened, drop into a select active to process the data.

The first active in your select active makes sure the HTTP return code is 

200

. If not, some error has 

occurred but luckily your call to 

DB_PROCESS_HTTP_HEADER

 has already processed all the errors 

and printed those errors to terminal. This call will detect standard HTTP errors as well as ASP 

script errors. ASP script errors may be generated by incorrect SQL so if something does not appear 

to work, check the terminal for a description of the problem.

If 

DB_PROCESS_HTTP_HEADER

 has returned a value of 200 (this is a HTTP code meaning OK), 

then there is data for to process. The first thing to do is look for your tag. This is the tag you sent 

with the request with a few extra characters added. The first is the 

</rs

 which signifies then end of 

an XML tag whose name is 

rs<Our Tag>

 where rs stands for record set. The trailing 

>

 is the end 

of the XML tag. One of the things our call to 

DB_PROCESS_HTTP_HEADER

 did for you was find the 

start of the XML packet. This is the point from which you begin your search.

Once we have identified what the response is to, we can process it. The next thing we do is pull out 

the list box information contained in the XML by calling 

DB_PROCESS_LISTBOX

. This function 

returns the position to begin to parsing for more information. You should expect to see a series of 

structures that represent your data. Simply loop as long as you can find 

<struct>

 in the XML 

Summary of Contents for DBWizard

Page 1: ...instruction manual integration Solutions i DatabasePlus and DBWizard...

Page 2: ...lity and your exclusive remedy shall be at AMX Corporation s option either a return of the price paid or b repair or replacement of the SOFTWARE that does not meet AMX Cor poration s Limited Warranty...

Page 3: ...ge SQL 5 HTTP CGI and XML 6 HTTP Hyper Text Transfer Protocol 6 CGI Common Gateway Interface 6 XML Extensible Markup Language 7 Creating an ASP file 9 Creating an AXI file 9 Creating an AXS file 15 Ne...

Page 4: ...i i Database Plus and DBWizard Table of Contents Webserver path 32 Absolute database path 32 NetLinx AXI file 32 NetLinx local IP port 32 NetLinx code prefix 32 Encapsulate 32 Writing Your AXS File 33...

Page 5: ...is an application that helps you generate NetLinx code to access a PC database The NetLinx Master can read and write to the database via a web server connection DBWizard helps generate the SQL and Ne...

Page 6: ...navigate to a directory other than the default install directory if desired Click Next 6 In the i Database Plus Shortcut Creation dialog select Install Shortcut Icons for the installed components on y...

Page 7: ...rnal Server Error message when trying to view ASP pages in a web browser the web server is not installed properly You must correct this problem before proceeding Once the server PC is setup make sure...

Page 8: ...Introduction 4 i Database Plus and DBWizard...

Page 9: ...connect to a database type not listed contact the vendor and obtain the ODBC drivers for that database 3 Connect to the database This will vary depending on the database you chose If you chose a Micro...

Page 10: ...CGI Common Gateway Interface CGI provides a simple way to pass parameters to a program from an HTTP request Most commonly the CGI parameters appear directly on the URL line For example http www someho...

Page 11: ...ata var var name TotalRecords name data 3 data var struct array struct index 1 index var name TitleID name data 11101000 data var array name Artist name string Buffet Jimmy string array array name Tit...

Page 12: ...llow Each record is wrapped in a struct struct pair and the columns of each record are represented by the var var pairs The index index pair represents the index into the array that this structure or...

Page 13: ...t 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 f...

Page 14: ...QL and database setup information When building SQL statements you need to know the names of the tables and or view and usually the names of any columns you are interested in reading or writing Anothe...

Page 15: ...that SQL considers invalid like spaces and dashes If you are using column names with these characters or continually get SQL syntax errors try wrapping the column names in a pair of brackets This is S...

Page 16: ...trSQL UPDATE Titles SET Artist 27 strArtist 27 Copyright 27 strCopyright 27 Label 27 strLabel 27 ReleaseDate 27 strReleaseDate 27 Title 27 strTitle 27 TitleID ITOA slTitleID WHERE TitleID ITOA slTitle...

Page 17: ...NT The first thing to do is create a series of variables that needed through the event To kick off the processing call DB_PROCESS_HTTP_HEADER which will parse the HTTP header information from the resp...

Page 18: ...T TO THE WEB SERVER CLEAR_BUFFER sDB_CLIENT strBUFF SEND_STRING dvDB_CLIENT dB_BUILD_HTTP_GET sDB_CLIENT OFFLINE EVENT OFFLINE STACK_VAR LONG lCODE HTTP RETURN CODE INTEGER nLIST_PTR INDEX FOR RECORDS...

Page 19: ...TAL 0 sTempListBox snTOTAL TYPE_CAST nLIST_PTR DB_DISPLAY_TITLES sDB_TITLES sTempListBox CLEAR BUFFER DB_ACK_QUE sDB_QUE sDB_CLIENT CLEAR_BUFFER sDB_CLIENT strBUFF The very last bit of code keeps your...

Page 20: ...text The last bit of code uses information contained in your listbox The first Send_Command displays record information in the form displaying 1 10 of 100 The listbox also has a value you can send to...

Page 21: ...y make sure the selected value is inside the selected list Using FFFF is an easy way to force the function to automatically position to the end of the list The last button is from your scroll bar slid...

Page 22: ...rted to XML tag CDATAit Converts XML Parameter to CDATA format The CDATAit function is used when converting record sets to XML Syntax CDATAit strData Variables strData Represents the data to be wrappe...

Page 23: ...es RunDBQuery returns an XML representation of a record set ErrorToXML Converts error code and descriptions to XML The ErrorToXML function is used to convert errors to XML Syntax ErrorToXML nNumber st...

Page 24: ...0 bytes above the max URL size nDB_MAX_PARAM_SIZE 300 XML PARAMETER SIZE Maximum size of XML values and ASP cookie nDB_MAX_QUE_SIZE 10 WEB SERVER QUE SIZE Number of commands to allow in queue nDB_LIST...

Page 25: ...ER NQ_TAIL QUEUE TAIL POINTER CHAR bQ_HAS_ITEMS 1 IF ANY ITEMS ARE IN THE QUEUE CHAR bQ_READY 1 IF READY TO SEND THE NEXT CMD INTEGER NQ_MAX MAXIMUM ENTRIES IN QUE CHAR bINIT 1 IF INIT STRUCTURE _sDB_...

Page 26: ...Variables sDB_QUE Represents the sDB_QUE for a given database server script connection Required srHDR Required Represents a header to be added to the XML response to identify the response Required st...

Page 27: ...turn code Required Return Values DB_GET_HTTP_ERROR returns a string formatted for the error code in the format HTTP_ERROR error code error description DB_GET_HTTP_HEADERS Reads the HTTP headers from a...

Page 28: ...r script connection Required nPORT Represents the IP port of the web server for a given database server script connection If 0 is supplied 80 will be used Required strFILE Represents the Path and File...

Page 29: ...Variable sTempListBox Represents the list box structure Required nIDX Represents the new starting index for the list box Required bFROM_SLIDER Set to 1 if value is a raw 0 255 value from a slider Requ...

Page 30: ...Extracts the HTTP Headers Cookie value from an sDB_CLIENT structure The DB_PROCESS_HTTP_HEADER function is used to parse the response from the server DB_PROCESS_HTTP_HEADER looks for HTTP errors and...

Page 31: ...haracters illegal in URL s are replaced with a hex code equivalent The DB_STRING_REPLACE function is used to convert SQL queries into CGI strings Syntax DB_MAKE_URL_STRING CHAR strSTR Variable strSTR...

Page 32: ...t be able to access the database There is a problem in the setup If the file is not found the path is likely to be wrong If the script cannot connect to the database the MDB file is not located in the...

Page 33: ...absolute paths for the database APS and AXI files If you move the project you will be prompted to look for the database Use the provided dialog to browse to the database The normal File menu New Open...

Page 34: ...en query name is moved to the Queries box in the bottom right you are ready to build your next query You can enter multiple queries for any table or view in the database if you want to get different i...

Page 35: ...you are finished If this file exists you will be prompted to overwrite it Webserver host name or IP address The address of the web server that is running the ASP file The NetLinx code will require th...

Page 36: ...uded in your program If this file exists you will be prompted to overwrite it You should note that DBWizard will re generate the AXI file listed in the NetLinx AXI File text box Any changes you made i...

Page 37: ...ou you still have some work to do The AXI generated by DBWizard now contains all the code necessary to read and write information to the database as well as the basic infrastructure required to send y...

Page 38: ...e richardson TX 75082 USA 469 624 8000 800 222 0193 fax 469 624 7153 technical support 800 932 6993 033 004 2565 01 05 2005 AMX Corporation All rights reserved AMX the AMX logo the building icon the h...

Reviews: