
Programming i!-Database Plus
12 i!-Database Plus and DBWizard
' VALUES (',$27,strArtist,$27,', ',$27,strCopyright,$27,',
',$27,strLabel,$27,', ',
$27,strReleaseDate,$27,', ',$27,strTitle,$27,',
',ITOA(slTitleID),')'"
(* SEND THE QUERY *)
DB_ADD_TO_QUE(sDB_QUE,'TITLES',strSQL,sTempListBox)
}
(*********************************************)
(* NAME: DB_UPDATE_TITLES *)
(***************************************************************************)
(* Format query to update an entry to TITLES data *)
(***************************************************************************)
DEFINE_FUNCTION DB_UPDATE_TITLES(CHAR strArtist[128],
CHAR strCopyright[128],
CHAR strLabel[128],
CHAR strReleaseDate[128],
CHAR strTitle[128],
SLONG slTitleID)
STACK_VAR
CHAR strSQL[1000]
_sDB_LISTBOX sTempListBox
{
(* ESCAPE ANY SINGLE QUOTES *)
strArtist = DB_STRING_REPLACE(strArtist,"39","39,39") (* ' FOR '' *)
strCopyright = DB_STRING_REPLACE(strCopyright,"39","39,39") (* ' FOR '' *)
strLabel = DB_STRING_REPLACE(strLabel,"39","39,39") (* ' FOR '' *)
strReleaseDate = DB_STRING_REPLACE(strReleaseDate,"39","39,39") (* ' FOR ''
*)
strTitle = DB_STRING_REPLACE(strTitle,"39","39,39") (* ' FOR '' *)
(* BUILD A QUERY STRING *)
strSQL = "'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(slTitleID)"
(* SEND THE QUERY *)
DB_ADD_TO_QUE(sDB_QUE,'TITLES',strSQL,sTempListBox)
}
(*********************************************)
(* NAME: DB_READ_TITLES *)
(***************************************************************************)
(* Format query to read a page of TITLES data *)
(***************************************************************************)
DEFINE_FUNCTION DB_READ_TITLES(_sDB_LISTBOX sTempListBox,CHAR strSEARCH[])
STACK_VAR
CHAR strSQL[1000]
{
(* BUILD A QUERY STRING *)
strSQL = "'SELECT * FROM Titles'"
IF (LENGTH_STRING(strSEARCH))
strSQL = "strSQL,' WHERE ',strSEARCH"
strSQL = "strSQL,' ORDER BY Artist'"
(* SEND THE QUERY *)
DB_ADD_TO_QUE(sDB_QUE,'TITLES',strSQL,sTempListBox)
}
The next section initializes the connection to the database script and creates a buffer to hold the
results. The call to DB_INIT_CLIENT initializes the sDB_CLIENT structure created in the variable
section. The parameters are the: IP address of the web server, IP port of the web server (usually 80)
and path to the database script. This path is the directory and file name of the ASP file. You will