Database Field Manipulation Problem 
Author Message
 Database Field Manipulation Problem

Hi,

 I am getting a weird error when trying to perform calculations on
datafields from an SQL database.  I am currently using Win32::OLE and
accessing the database via ODBC.

Once i load my recordset and grab the values from two field and try and
perform a calculation the result is a number in the trillions when it should
only be in the 100's

is it possible that somehow perl is calculating not only the value of the
recordsetfield, but the ID tag or something?  I can provide some sample code
to show this.

I have also talked to our DB programmers and they are stumpped.

One more thing.  If I do not perform a mathmatical calculation it displays
the true value of the recordset field.

Thanks for any help inadvance,
Andre



Sun, 26 Jan 2003 03:00:00 GMT  
 Database Field Manipulation Problem

Quote:

> Once i load my recordset and grab the values from two field and try and
> perform a calculation the result is a number in the trillions when it should
> only be in the 100's

Can you provide a complete sample program (of a couple dozen lines or less)
that prints the actual values of the two fields and the result of
the calculation?


Sun, 26 Jan 2003 03:00:00 GMT  
 Database Field Manipulation Problem
Oh i do beleive that the value of the recordset is being added to 20, but I
am not sure if this is a physical memory address or what.  I could be
completely wrong. but my problems lies in the fact that i dont know the
correct syntax.

Regards,
Andre


Quote:


> > Once i load my recordset and grab the values from two field and try and
> > perform a calculation the result is a number in the trillions when it
should
> > only be in the 100's

> Can you provide a complete sample program (of a couple dozen lines or
less)
> that prints the actual values of the two fields and the result of
> the calculation?



Mon, 27 Jan 2003 03:00:00 GMT  
 Database Field Manipulation Problem


Quote:


> > Once i load my recordset and grab the values from two field and try and
> > perform a calculation the result is a number in the trillions when it
should
> > only be in the 100's

> Can you provide a complete sample program (of a couple dozen lines or
less)
> that prints the actual values of the two fields and the result of
> the calculation?

Hi thanks for the reply.  Here is the script we wrote strictly for a test:
You can view the complete output at this URL its simple:

http://www.laserefx.com/arena/sampleio.asp

Print two names from the database and take some stats, display them, then
add them together.

Both results should be either 20 or 40:  We have reset every value in our
database to 20....  Good luck =)

----------------------------


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<%
use Win32::OLE;
use Win32::OLE::Const;
$Win32::OLE::Warn = 3;
my $conn = Win32::OLE->new("ADODB.Connection", "Close");
$conn->Open('GladDB', '', '');

$Name1 = 'Maximus';
$Name2 = "Absolom";

my $rs1 = Win32::OLE->new("ADODB.Recordset");
my $const = Win32::OLE::Const->Load($rs1);
eval { $rs1->Open("SELECT * FROM GladWHERE GladiatorName='Maximus'", $conn,
$$const{adOpenKeyset}, $$const{adLockOptimistic}); };

$Dex1=$rs1->{Dex}; ## Displays the correct number
$Health1=$rs1->{Health}; ## Displays the correct number
$Int1=$rs1->{Int}; ## Displays the correct number

$Stack1 = 1+1;
$x = $rs1->{Dex}+$rs1->{Str};  ##### HERE this is 20+20  $x = 20+20 but is
comming up with a billion something.
$Stack1 = $rs1->{Str}; ## Displays the correct number

$Stack1 = $rs1->{Int}+$rs1->{Dex}+$rs1->{Health} +
$rs1->{Int}+$rs1->{Dex}+rand($rs1->{Health}) +
$rs1->{Int}+$rs1->{Dex}+rand($rs1->{Health})+42;  ## This line doesnt
compute, it too comes up with a wacko nunber.

%>Name :  <%=$rs2->{GladiatorName}%> Stack : <%=$rs2->{Int}%><BR><% ##
Displays the correct name & number
%>Name :  <%=$rs1->{GladiatorName}%> Stack : <%$Response->write($x);%><BR><%
$x=0;

%>
</body>



Mon, 27 Jan 2003 03:00:00 GMT  
 Database Field Manipulation Problem

Quote:

> Oh i do beleive that the value of the recordset is being added to
> 20, but I am not sure if this is a physical memory address or what.
> I could be completely wrong. but my problems lies in the fact that i
> dont know the correct syntax.

You appear to have a working program already, only it produces wrong
results.  Please take that program, try to make it short while still
exhibiting the problem, then post the program.

Without the program, nobody knows what you have tried to do and thus
it is not possible to tell you what's wrong with your approach.

kai
--
I like BOTH kinds of music.



Mon, 27 Jan 2003 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. pack Table

2. Database manipulation Problems... Deleting a Line

3. Interesting database manipulation problem

4. Text manipulation with packed fields

5. Mail::Mailer problem - to: field twice, subject: field ignored

6. Advantage

7. E-Mail Query

8. Parallel port I/O code needed.

9. New Web Site

10. Database Manipulation Tools?

11. Help with Access Database manipulation

12. database manipulation

 

 
Powered by phpBB® Forum Software