ScriptBasic
February 10, 2012, 11:27:43 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Registration Disabled Send an e-mail to support @ scriptbasic.org to request a membership to this forum. (include desired forum name)
 
   Home   Wiki Help Search Login Register  
Pages: [1]
  Print  
Author Topic: CGI - ODBC Example  (Read 2236 times)
support
Administrator
*****
Posts: 369


« on: March 26, 2006, 06:45:03 PM »

http://www.scriptbasic.org/cgi-bin/odbctest.bas



Code:
#!/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 » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!