Ich möchte das Ergebnis einer Datenbankabfrage in einer Listbox, die schon existiert einfügen.Bisher habe ich folgenden Code:
#!C:\Perl\bin\perl.exe
use Tk;
use DBI;
my ($dbh, $sth, $anz);
$dbh = DBI->connect ("DBI:mysql:host=localhost;database=vorrat",
"root", "master#1",
{PrintError => 0, RaiseError => 1});
my $mw =MainWindow ->new;
$mw -> title ("Löschen von Vorratsartikeln ");
$mw -> Label(-textvariable=> \"Artikel",-borderwidth => 5,-relief=> 'groove')->grid (
$mw -> Label(-textvariable=> \"genau",-borderwidth => 5,-relief=> 'groove'), -sticky =>"snew");
$e_artikel = $mw ->Entry(-textvariable =>\$artikel)->grid(
$e_genau= $mw ->Entry(-textvariable =>\$genau), -sticky =>"snew");
$mw -> Button(-text => "anzeigen",-background => "lightblue", -command => \&anzeige)-> grid (
$mw -> Button(-text => "Ende", -background => "red",-command => sub {exit} ), -sticky =>"snew");
$lb = $mw -> Listbox (-selectmode =>"single", -setgrid =>1) -> grid (-sticky => "snew", -columnspan => 3);
MainLoop;
$sth->finish ();
$dbh->disconnect ();
exit (0);
sub anzeige {
$sth = $dbh->prepare ("select artikel, genau, id from anfang where artikel ='$artikel and genau ='$genau'");
$sth->execute ();
#print "@anzeige\n":
}
Wie binde ich jetzt, dass Ergebnis aus der Datenbank-Abfrage in meine listbox ein?
Ich freue mich auf Antworten.
Datum: 09.01.2005-08:38
