use CGI qw/:standard :html3 :netscape/;
use Win32::ODBC;
# Unpack parameters from form
$cmd=param('cmd'); #Command to processs
$DSN=param('DSN'); #Selected DSN
$table=param('table'); #Selected table from DSN
@cols=param('cols'); #Selected columns from table
$sort=param('sort'); #Column to sort on
$rows=param('rows'); #Max number of rows
# Off we go...
# If no command or DSN then get user to select one.
if ($cmd eq '' || $DSN eq ''){
%DSN=Win32::ODBC::DataSources; #Get list of datasources
@keys=sort(keys(%DSN)); #put list of DSNs into array
&screen_header; #Start HTML response
print start_form,
hidden(-name=>'cmd',-value=>'table',-force=>1),
table(
Tr([
td(['Data Source: ',
popup_menu(-name=>'DSN',-value=>\@keys)."   ".submit(-name=>'GO')])
])
),
end_form,
hr,
end_html;
exit(0);
}
# If no table selected then get table name
if ($cmd eq 'table' || $table eq ''){
$db=new Win32::ODBC($DSN);
#create new instance
if (! $db){
perror("Error opening data source $DSN");
exit(0);
}
@tables=$db->TableList("","","","TABLE"); #Get list of tables