Gossamer Forum
Home : General : Perl Programming :

Help required on inserting the Data in the Table

Quote Reply
Help required on inserting the Data in the Table
Hi..
I am new to the Perl programming
I am facing a problem with insertig the Data in the Database Table.I am using the MS ACCESS
I am able to retrieve the Data from the Databse Table but when it come to insertions I am not able to do so.
plz help me.
This is the code which I am trying to execute.I am not getting any error but the Data is not coming to the Table
This is the subroutine for connecting to the Database.
====================================================================================================================
sub connectDB(){
$DSN = "MEXP";
$db = Win32::ODBC->new($DSN);

if (!$db) {
print "Failed to connect to Database";
Win32::ODBC::DumpError();
}
else
{
#print "Got Connected\n\n";
print "\n";
}
}
====================================================================================================================


I have written this subroutine for Time
sub Time(){
my($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
$Year = 2 .$Year-100;
$Time = ("$Hour:$Minute:$Second");
$Date = ("$Day-$Month-$Year");
}
=================================================================================================================
print "Enter Your Name:- ";
chomp(my $Name = <STDIN>);
print "Enter The Amount:-";
chomp(my $Amount = <STDIN>);
print "Enter The Description:-";
chomp(my $Description = <STDIN>);
my $query = "INSERT INTO MONTHLY(Name,Time,Date,Amount,Description)";
$query .= "VALUES ($Name,$Time,$Date,$Amount,$Description)";
print "\n";
my $Insert_Record = $db->sql($query)|| die "Fetch Error: ",$db->Error();
print $Insert_Record;
print "Your Expense has been logged!";
}

please help me here ASAP