我做了个单机版库存管理,ADO连接,所有出库/入库/更新都通过一个Query用SQL完成。但是莫名其妙的出现数据丢失现象---所有操作正常,不定时出现关闭程序后输入的大部分丢失,并似乎输入出库数据多时易发。跟踪没有发现异常。
我用win2k+Access2k,客户平台是win98+Access2k,在客户机其商业调试编译过。
请指教:(
我用win2k+Access2k,客户平台是win98+Access2k,在客户机其商业调试编译过。
请指教:(
解决方案 »
- DELPHI 如何自身工程版本信息
- 今天终于骗了点分数,散分~~~~~~~~~
- 我在作权限分配时遇到: 在LISTVIEW中显示窗体名、和打构的一个框框(LISTVIEW),
- DATASOURCE改变事件是什么??急
- 被香港人骂!不爽!唉!!
- 进程问题
- delphi中的sql语句
- 用控件可以打印并预览DBGridEH控件中的表格数据,但DBGrid控件中的数据应该怎样才能做到可以打印并预览?
- 如何控制tabe1 query1 控件的编缉例如 保存,撤弃象foxpror TABLEUPDATE()函数 or TABLEREVERT()函数,DeLphi有没有缓冲的概念
- 用的是阿ADOQUERY,如果保证数据的完整性啊?
- UP有分!急!!ClientDataset连接一张一万条记录的表,为什么我的记录却保存不了??
- 如果我做了一个发票打印程序,如果换了一个打印机,会不会出现偏差?
(**) if database1.InTransaction then
database1.rollback; frmd.database1.StartTransaction ;try
database1.StartTransaction;
//你的数据提交代码
database1.commit;
except
database1.rollback;
end;
begin
try
dm.aCnn.BeginTrans;
SavetoSales; //先更新销售主表
with dm.aQrGen do //更新销售详表
begin
if active then close;
sql.Clear;
sql.Add('insert into saledetails (sid,pname,sqty,sprice,pprice,re)'
+ ' values(' + ''''+edtsid.Text+'''' +','+''''+edtpname.Text+''''
+',' + edtsqty.Text+','+ edtsprice.Text + ',' + edtprice.Text
+','+''''+SEstr+''''+ ')');
ExecSql;
end;
dm.aCnn.CommitTrans;
ClearEdtSales;
RefreshGrid(dm.aTabSDetail);
RefreshGrid(dm.aTabSales);
Result := true;
except
begin
dm.aCnn.RollbackTrans;
raise exception.Create('保存错误!请检查输入重试!');
end;
end;
end;
function FrmMain.SavetoSales: boolean;
with dm.aQrSales do
begin
if active then close;
sql.Clear;
sql.Add('select * from sales where sid='+''''+edtsid.Text+'''');
open;
if recordcount <> 0 then
SQLstr := 'update sales set mqty=mqty+'+edtsqty.Text+',maccount=maccount+'
+floattostr(strtofloat(edtsqty.Text)*strtofloat(edtsprice.Text))
+' Where sid='+''''+EdtSID.text+''''
else
SQLstr :='insert into sales(sid,mqty,maccount,sdate,suser,customer,tel)'
+' values('+''''+edtsid.Text+''''+','+edtsqty.Text+','
+floattostr((strtofloat(edtsprice.Text))*(strtofloat(edtsqty.Text)))
+',#'+edtsdate.Text+'#,'+''''+edtuser.Text+''''+','+''''
+edtcust.Text+''''+','+''''+edttel.Text+''''+')';
close;
sql.Clear;
sql.Add(sqlstr);
ExecSQL;
close;
//更新产品库
UpdatePQty(edtsqty.Text,fpid,false);
Result := true;
end;
end;
function TFrmMain.Save: Boolean;
begin
Result := False ;
dm.aCnn.BeginTrans;
if not SavetoSales then Exit ;
with dm.aQrGen do //更新销售详表
begin
Close ;
sql.Clear;
sql.Add('insert into saledetails (sid,pname,sqty,sprice,pprice,re)'
+ ' values(' + ''''+edtsid.Text+'''' +','+''''+edtpname.Text+''''
+',' + edtsqty.Text+','+ edtsprice.Text + ',' + edtprice.Text
+','+''''+SEstr+''''+ ')');
ExecSql;
end;
try
dm.aCnn.CommitTrans;
Result := true;
except
begin
dm.aCnn.RollbackTrans;
raise exception.Create('保存错误!请检查输入重试!');
end;
end;
end;function FrmMain.SavetoSales: boolean;
begin
Result := Fasle ;
with dm.aQrSales do
begin
Close ;
sql.Clear;
sql.Add('select * from sales where sid='+''''+edtsid.Text+'''');
open;
if recordcount <> 0 then
SQLstr := 'update sales set mqty=mqty+'+edtsqty.Text+',maccount=maccount+'
+floattostr(strtofloat(edtsqty.Text)*strtofloat(edtsprice.Text))
+' Where sid='+''''+EdtSID.text+''''
else
SQLstr :='insert into sales(sid,mqty,maccount,sdate,suser,customer,tel)'
+' values('+''''+edtsid.Text+''''+','+edtsqty.Text+','
+floattostr((strtofloat(edtsprice.Text))*(strtofloat(edtsqty.Text)))
+',#'+edtsdate.Text+'#,'+''''+edtuser.Text+''''+','+''''
+edtcust.Text+''''+','+''''+edttel.Text+''''+')';
close;
sql.Clear;
sql.Add(sqlstr);
ExecSQL;
//更新产品库 UpdatePQty(edtsqty.Text,fpid,false); // 也是一个函数 ? Result := true;
end;
end;