use strict;
use Tk;
use Win32::ODBC;

my @Data;
my $db;
my $dsn = "x";								# <- put the name of your database in place of x
my $statement = "SELECT * FROM x";			# <- put the name of your table in place of x

my $top = MainWindow->new;
$top->title('SQL Front End');

if (!($db = new Win32::ODBC($dsn))){
	print "Error connecting to $dsn\n";
	print "Error: " . Win32::ODBC::Error() . "\n";
	exit;
}
      
if ($db->Sql($statement)){
		print "SQL failed.\n";
		print "Error: " . $db->Error() . "\n";
		$db->Close();
		exit;
}

while($db->FetchRow()){
	@Data = $db->Data();
	my $label = $top->Label(-text => "@Data\n");
	$label->pack();
}

my $button = $top->Button(-text => 'Quit',
						  -command => \&on_quit,
						  )->pack();

MainLoop;

$db->Close();

sub on_quit {
	exit 0;;
}

=head1 NAME

sqltk - This script connects to an SQL table and prints out the information in Tk.

=head1 DESCRIPTION

This program is useful for grabbing the information out of SQL for viewing on a workstation.

=head1 README

This script connects to an SQL table and prints out the information in Tk.  This script provides the groundwork for an SQL front end.

=head1 PREREQUISITES

This script has a few requirements.  You will need the Win32::ODBC and Tk modules.
You will also need to change the values for dsn and the SQLstatment.

=head1 COREQUISITES

None

=pod OSNAMES

MSWin32

=pod SCRIPT CATEGORIES

Win32/Utilities 

=cut