February 28, 2008 at 9:13 pm
Hi,ALL
My name is Jeff and I have a puzzling problem with a very simple program.
Groundwork... Visual Studio 2005 Pro using as a Language / Visual Basic 2005
Winforms .net 2.0 SQL Express SP2 / SQL .mdf Database File Used.
I am trying to build my dad a program to calculate and log his mileage on
his 2 Cars. SQL Database Record Number (Key Indexed), DATE, Miles_Start,
Miles_Stop, Total_Miles, Gallons_FillUp, & MPG (In a DataGrid). The Equasion
is simple: Miles_Stop - Miles_Start = Miles_Total / Gallons_FillUp = MPG. I
think(I know why does he... ) everything goes fine with the miles_stop
minus the miles_start = Miles_Total that works fine and correctly puts the
Miles_Total in and when I change either the Miles_Stop or the Miles_Start
the Miles_Total Changes (OK So Far) But in the SQL Query Box Running the
Query Results in A NULL in the MPG Column! Also reflected in the built
Program No MPG Computation. Also when Running the Query in the Query
Builder the Query Makes another Column (MPG1) Below is What I have
Entered in the Query Builder Box. HELP! jrlvid@hughes.net
Thanks in Advance...
Jeff Link AS., B.S.
NEW TEXT:
The record number,date,car,miles_stop,miles_start & Gallons Fullup
are all non null entry's but when you consider that when you take the
miles_stop - miles_start = miles_total into consideration, does the
miles_total being a computation displayed correctly on the screen
and computed right still be considered a NULL when the SQL Query
is run? is that where the rub comes in? i think so... as ther SQL
Query is checked for errors before it gets into the workings of the
program's datagrid. dividing 0 by anything is a NULL... Someone
Please correct my SQL and I'll be ever so thankfull as I am green
to this all.
SELECT [Record Number], Date, Car, Gallons_FillUp, Miles_Start, Miles_Stop, MPG, Miles_Stop - Miles_Start AS Miles_Total, Miles_Total / Gallons_FillUp AS MPG
FROM Sheet1_Table
February 29, 2008 at 9:17 am
Why do you have two MPG fields in the query? Seems that one is taken from table (and is NULL) and the second is calculated and aliased to the same name.
Piotr
...and your only reply is slàinte mhath
February 29, 2008 at 11:38 am
All Columns fine 2 dummy database entry's all fine
except the MPG it has a NULL in it... I took out the
other ,MPG and still it won't calculate the SQL Query.
SELECT [Record Number], Date, Car, Gallons_FillUp, Miles_Start, Miles_Stop, Miles_Stop - Miles_Start AS Miles_Total, Miles_Total / Gallons_FillUp AS MPG
FROM Sheet1_Table
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply