<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use strict;
use Tk;
use Win32::ODBC;

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

my $top = MainWindow-&gt;new;
$top-&gt;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-&gt;Sql($statement)){
		print "SQL failed.\n";
		print "Error: " . $db-&gt;Error() . "\n";
		$db-&gt;Close();
		exit;
}

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

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

MainLoop;

$db-&gt;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
</pre></body></html>