2
2000888
Unregistered / Unconfirmed
GUEST, unregistred user!
我用ado+delphi+access:
adoquery1.close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from ');
adoquery1.sql.Add('(select 学号,姓名,sum(迟到) as 迟到 ,sum(早退) as 早退,sum(旷操) as 旷操,sum(旷课) as 旷课,sum(迟到)*1/2+sum(早退)*1/2+sum(旷操)+sum(旷课) as 折算旷课 from b1');
adoquery1.sql.Add(' group by 学号,姓名)');
adoquery1.sql.Add(' where 折算旷课>=:cc1');
adoquery1.Parameters.ParamByName('cc1').Value :=21; //strtoint(edit1.Text);
open;
竟然查出“折算旷课”有大于21和[red]小于21的[/red]。(错误)
改成这样后:
adoquery1.close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from ');
adoquery1.sql.Add('(select 学号,姓名,sum(迟到) as 迟到 ,sum(早退) as 早退,sum(旷操) as 旷操,sum(旷课) as 旷课,sum(迟到)*1/2+sum(早退)*1/2+sum(旷操)+sum(旷课) as 折算旷课 from b1');
adoquery1.sql.Add(' group by 学号,姓名)');
adoquery1.sql.Add(' where 折算旷课>=21');
//adoquery1.Parameters.ParamByName('cc1').Value :=21; //strtoint(edit1.Text);
open;
就只查出“折算旷课”大于21的(正确)
为什么用了动态变量就不对了呢?错在哪
adoquery1.close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from ');
adoquery1.sql.Add('(select 学号,姓名,sum(迟到) as 迟到 ,sum(早退) as 早退,sum(旷操) as 旷操,sum(旷课) as 旷课,sum(迟到)*1/2+sum(早退)*1/2+sum(旷操)+sum(旷课) as 折算旷课 from b1');
adoquery1.sql.Add(' group by 学号,姓名)');
adoquery1.sql.Add(' where 折算旷课>=:cc1');
adoquery1.Parameters.ParamByName('cc1').Value :=21; //strtoint(edit1.Text);
open;
竟然查出“折算旷课”有大于21和[red]小于21的[/red]。(错误)
改成这样后:
adoquery1.close;
adoquery1.sql.Clear;
adoquery1.sql.Add('select * from ');
adoquery1.sql.Add('(select 学号,姓名,sum(迟到) as 迟到 ,sum(早退) as 早退,sum(旷操) as 旷操,sum(旷课) as 旷课,sum(迟到)*1/2+sum(早退)*1/2+sum(旷操)+sum(旷课) as 折算旷课 from b1');
adoquery1.sql.Add(' group by 学号,姓名)');
adoquery1.sql.Add(' where 折算旷课>=21');
//adoquery1.Parameters.ParamByName('cc1').Value :=21; //strtoint(edit1.Text);
open;
就只查出“折算旷课”大于21的(正确)
为什么用了动态变量就不对了呢?错在哪