这样的程序:
dstDetail:=TADODataSet.Create(self);
try
dstDetail.Connection:=dmMain.DBConnection;
dstDetail.CommandType:=cmdText;
dstDetail.CommandText:=
'select sum(qty) as qty,sum(total) as total from consignmentdetail where billnumberID=:billnumberID';
dstDetail.Parameters.ParamByName('billnumberID').Value:=BillnumberID;
dstDetail.Active:=true;
dstConsignmentForm.FieldByName('totalmoney').AsCurrency:=dstDetail.FieldbyName('total').AsCurrency; //A
dstConsignmentForm.FieldByName('totalqty').AsInteger:=dstDetail.FieldbyName('qty').AsInteger ; //B
dstConsignmentForm.UpdateBatch;
finally
dstDetail.Free;
end;最后上面的select sum(qty) as qty,sum(total) as total from consignmentdetail where billnumberID=:billnumberID 运行完明明有两个字段一条记录,是有值的,无论是在查询分析器中还是用事件探查器,都表是是自常运行的.
可是最后程序运行完totalmoney和totalqty的值仍为0,在上面//A和//B处设断点发现
dstConsignmentForm.FieldByName('totalmoney').AsCurrency和 dstConsignmentForm.FieldByName('totalqty').AsInteger的值都是0,倒~~~~
如果数据类型都用.Value那就成了null仍没有值,也不报错,就是没有值,totalmoney和totalqty在表中字段类型为money和int.
另外改用Tadoquery也这样.是哪有问题啊???
dstDetail:=TADODataSet.Create(self);
try
dstDetail.Connection:=dmMain.DBConnection;
dstDetail.CommandType:=cmdText;
dstDetail.CommandText:=
'select sum(qty) as qty,sum(total) as total from consignmentdetail where billnumberID=:billnumberID';
dstDetail.Parameters.ParamByName('billnumberID').Value:=BillnumberID;
dstDetail.Active:=true;
dstConsignmentForm.FieldByName('totalmoney').AsCurrency:=dstDetail.FieldbyName('total').AsCurrency; //A
dstConsignmentForm.FieldByName('totalqty').AsInteger:=dstDetail.FieldbyName('qty').AsInteger ; //B
dstConsignmentForm.UpdateBatch;
finally
dstDetail.Free;
end;最后上面的select sum(qty) as qty,sum(total) as total from consignmentdetail where billnumberID=:billnumberID 运行完明明有两个字段一条记录,是有值的,无论是在查询分析器中还是用事件探查器,都表是是自常运行的.
可是最后程序运行完totalmoney和totalqty的值仍为0,在上面//A和//B处设断点发现
dstConsignmentForm.FieldByName('totalmoney').AsCurrency和 dstConsignmentForm.FieldByName('totalqty').AsInteger的值都是0,倒~~~~
如果数据类型都用.Value那就成了null仍没有值,也不报错,就是没有值,totalmoney和totalqty在表中字段类型为money和int.
另外改用Tadoquery也这样.是哪有问题啊???
dstDetail.FieldbyName('total').AsCurrency;和
dstDetail.FieldbyName('qty').AsInteger 的值都是0,反正就都是0了,赋完值左边也是0蛋,就是没值.而且断点处查看dstDetail.recordcount是1说明有记录,就是字段里没值.但事件探查器里生成的exec sp_executesql N'select sum(qty) as qty,sum(total) as total from consignmentdetail where billnumberID=@P1
', N'@P1 int', 7 明明运行出来是有值的.