background image

Programming i!-Database Plus

21

i!-Database Plus and DBWizard

Structures 

STRUCTURE _sDB_CLIENT

{

CHAR

strBUFF[10000]

(* BUFFER FOR XML *)

CHAR

strQUERYSTRING[1000]

(* QUERY STRING *)

CHAR

strWEB_SERVER[100]

(* IP OR NAME OF SERVER *)

CHAR

strDB_ASP_FILE[100]

(* FILE NAME/PATH OF DB ASP FILE *)

INTEGER

nWEB_PORT

(* PORT WEB SERVER IS LISTENING ON *)

CHAR

strASP_COOKIE[300]

(* ASP COOKIE *)

DEV

dvSOCKET

(* LOCAL PORT HANDLE/DEVICE *)

INTEGER

nMAX_TIMEOUT

(* MAXIMUM TIMEOUT IN SECONDS *)

INTEGER

nTO_COUNT

(* TIMEOUT COUNT *)

CHAR

bTO_LO

(* TIMEOUT LOCKOUT *)

LONG

lHTML_START

(* POSITION OF HTML SEQUENCE *)

CHAR

nVERSION_CHECK

(* 1 IF WE CHECKED VERSION *)

}

STRUCTURE _sDB_QUE

{

CHAR

strQUEUE[10][2000]

(* QUEUED COMMANDS *)

INTEGER

nQ_HEAD

(* QUEUE HEAD POINTER *)

INTEGER

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_HTTP_HEADERS

{

CHAR

strHTTP_PROT[20]

(* HTTP PROTOCOL VERSION *)

LONG

lHTTP_CODE

(* HTTP RETURN CODE *)

CHAR

strHTTP_DESC[100]

(* RETURN DESCRIPTION *)

CHAR

strHTTP_SVR [100]

(* SERVER DESCRIPTION *)

CHAR

strHTTP_DATE[100]

(* SERVER DATE *)

CHAR

strHTTP_CTYPE[100]

(* CONTENT TYPE *)

LONG

lHTTP_CLENGTH

(* CONTENT LENGTH *)

CHAR

strHTTP_COOKIE[300]

(* COOKIE FROM SERVER *)

}

STRUCTURE _sDB_LISTBOX

{

SINTEGER

snFIRST

(* FIRST ENTRY IN THE LIST BOX DISPLAY *)

SINTEGER

snLAST

(* LAST ENTRY IN THE LIST BOX DISPLAY *)

INTEGER

nDISPLAY_SIZE

(* NUMBER OF ITEMS TO LIST PER PAGE *)

SINTEGER

snTOTAL

(* TOTAL NUMBER OF ITEMS *)

INTEGER

nLEVEL_VAL

(* LEVEL VALUES FOR SLIDER POSITION (0-255) *)

INTEGER

nCOUNT

(* COUNT OF ITEMS ON CURRENT PAGE *)

INTEGER

nPNL_IDX

(* VALUE: PANEL INDEX *)

}

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: