Author Topic: CGI - ODBC Example  (Read 12188 times)

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
CGI - ODBC Example
« on: March 26, 2006, 06:45:03 PM »
http://www.scriptbasic.org/cgi-bin/odbctest.bas



Code: [Select]
#!/usr/bin/scriba -c

INCLUDE cgi.bas
INCLUDE odbc.bas

cgi::Header 200,"text/html"
cgi::FinishHeader

PRINT """
<HTML>
<HEAD>
<title>unixODBC testing</title>
</HEAD>
<BODY>
<FONT face="Verdana, Arial, Helvetica, sans-serif">
<TABLE border="1" cellpadding="3">
"""

ON ERROR GOTO PROBLEMS

dbh = ODBC::RealConnect("DSN","user","password")

ODBC::query(dbh,"SELECT * FROM contact")

PRINT "File Handle: <b>",dbh,"</b><br>"
PRINT "Affected Rows: <b>",ODBC::AffectedRows(dbh),"</b><br>"

WHILE ODBC::FetchHash(dbh,column)

PRINT "<TR>"
PRINT "<TD>",column{"ID"},"</TD>"
PRINT "<TD>",column{"NAME"},"</TD>"
PRINT "<TD>",column{"ADDRESS"},"</TD>"
PRINT "<TD>",column{"CITY"},"</TD>"
PRINT "<TD>",column{"STATE"},"</TD>"
PRINT "<TD>",column{"ZIP"},"</TD>"
PRINT "<TD>",column{"PHONE"},"</TD>"
PRINT "<TD>",column{"EMAIL"},"</TD>"
PRINT "<TD>",column{"URL"},"</TD>"
PRINT "</TR>"

WEND

PRINT """
</TABLE>
</FONT>
</BODY>
</HTML>
"""

ODBC::Close(dbh)

END

PROBLEMS:

PRINT "ERROR = ",error(),"<br>"

RESUME
« Last Edit: July 25, 2009, 09:30:06 PM by support »
Script BASIC Project Manager