
mohsenalizadeh
Novice
Mar 22, 2010, 8:22 AM
Post #12 of 14
(15837 views)
|
Re: [FishMonger] problem with select quary when I convert program to .exe file
[In reply to]
|
Can't Post
|
|
I fixed this problem , then my code is :
#!C:/strawberry/perl/bin/perl.exe use Tk; use DBI; use DBD::mysql; use strict; use warnings; our $name; our $adminname; our $myphone1; our $myphone2; our $myaddress; our $mypercent; my $cn = DBI->connect("DBI:mysql:telephontaxi","root","root",{mysql_enable_utf8 => 1,RaiseError => 1}) or die("Cant Connected to Databses...."); my $dbh = $cn->prepare("select * from telephonetaxiinformation"); $dbh->execute(); while(our @rec = $dbh->fetchrow_array()){ $name = $rec[1]; $adminname = $rec[2]; $myphone1 = $rec[3]; $myphone2 = $rec[4]; $myaddress = $rec[5]; $mypercent = $rec[6]; } $dbh->finish; $cn->disconnect; my $mw = MainWindow->new(-background=>"gray"); $mw->title("header"); $mw->maxsize(800,315); $mw->minsize(800,315); $mw->Label(-text=>"header",-font => "Titr 23",-anchor=>'center',-width=>34,-background=>"gray")->place(-x => 0,-y=>0); my $fram = $mw->Frame(-relief => 'groove',-borderwidth => 0,-width=>780,-height=>240)->place(-x => 10,-y=>64); $fram->Label(-text => "name")->place(-x =>650,-y=>15); $fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief =>'groove',-textvariable => \$name)->place(-x =>410,-y=>15); $fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief =>'groove',-textvariable => \$adminname)->place(-x =>410,-y=>55); $fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief =>'groove',-width=>4,-textvariable => \$mypercent)->place(-x =>170,-y=>30); $fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief =>'groove',-textvariable => \$myphone1)->place(-x =>410,-y=>95); $fram->Entry(-font => "Tahoma 13 normal",-justify =>'right',-relief =>'groove',-textvariable => \$myphone2)->place(-x =>50,-y=>95); $fram->Entry(-font => "Tahoma 13 normal",-width=>60,-justify =>'right',-relief =>'groove',-textvariable => \$myaddress)->place(-x =>50,-y=>145); $fram->Button(-text=>"Save",-font => "Tahoma 13 normal",-command => [ \&saveinformation ])->place(-x =>370,-y=>190); $fram->Button(-text=>"Exit",-font => "Tahoma 13 normal",-command => [$mw => 'destroy'])->place(-x =>320,-y=>190); MainLoop; sub saveinformation{ $cn = DBI->connect("DBI:mysql:telephontaxi","root","root",{mysql_enable_utf8 => 1,RaiseError => 1}); $dbh = $cn->prepare("update telephonetaxiinformation set azansname='$name',azansadmin='$adminname',phone1='$myphone1', phone2='$myphone2',azansaddress='$myaddress',azanspercent='$mypercent' where azansid='1'"); $dbh->execute(); $cn->disconnect; $dbh->finish; my $cn1 = DBI->connect("DBI:mysql:telephontaxi","root","root",{mysql_enable_utf8 => 1,RaiseError => 1}); my $dbh1 = $cn1->prepare("select azansid from telephonetaxiinformation where azansname='$name'"); $dbh1->execute(); my @rec = $dbh1->fetchrow_array(); print $rec[0]; if($rec[0] ne ""){ my $message = "save correctly..."; $fram->Label(-text=>"$message",-font => "homa 15")->place(-x =>600,-y=>190); $mw->messageBox ( -default => 'Ok', -title => "$message", -message => "$message", -type => 'Ok', ); } $dbh1->finish; $cn1->disconnect; }
|