我在做超市销售的课程设计,功能简单,我希望运行后在界面里向数据库的一个表中插入顾客所购货物的信息:货号(edit1Str:文本框1的输入值),品名(goodsName:根据输入的货号从表中查询所得),数量(edit2Str:文本框2的输入值),单价(goodsPrice:根据输入的货号从表中查询所得)。
插入代码如下所示:
sqlStr2:='insert into sale values('''+edit1Str+''','''+goodsName+''','''+edit2Str+''','''+goodsPrice+''')';
Table1.Active:=False;
with Query2 do
begin
Close;
SQL.Clear;
SQL.Add(sqlStr2);
Open;
end;
Table1.Active:=True;
每插入一次,DBGrid刷新Table1的内容,显示在界面上,可是一运行,总是在插入时出错。
错误提示:Project Project1.exe raised exception class ENoResultSet with message 'Error creating cursor handle'
请问如何解决?谢谢!
插入代码如下所示:
sqlStr2:='insert into sale values('''+edit1Str+''','''+goodsName+''','''+edit2Str+''','''+goodsPrice+''')';
Table1.Active:=False;
with Query2 do
begin
Close;
SQL.Clear;
SQL.Add(sqlStr2);
Open;
end;
Table1.Active:=True;
每插入一次,DBGrid刷新Table1的内容,显示在界面上,可是一运行,总是在插入时出错。
错误提示:Project Project1.exe raised exception class ENoResultSet with message 'Error creating cursor handle'
请问如何解决?谢谢!
SQL.Clear;
SQL.Add(sqlStr2);
execute;
就行了
麻烦大家再帮我看个问题
顾客的购物记录放在sale表中,四个属性:货号(int),品名(char),数量(int),单价(char)。我想在“Table1.Active:=True;”时,也就是显示sale表数据的时候计算总价,显示出来,如何做呢?
有什么函数或方法可用吗?
小弟感谢所有帮忙的人^_^
这样对吗?如何取出得到的值?
怎么没有人帮忙呢?小弟急等,多谢啦!
( 货号 int not null,
品名 char(20) not null,
数量 int not null,
单价 float not null,
总价 as 数量*单价, --计算列
primary key(货号)
)
select sum(总价) from sale;
这样对吗?如何取出得到的值?
查询结果怎么取出来?麻烦大家帮忙看看,谢谢!