在线程里操作数据库,当给执行下面操作时
adocommand.commandtext := SQLStr;
出错,如题。
各位赐教啦!
adocommand.commandtext := SQLStr;
出错,如题。
各位赐教啦!
解决方案 »
- 简单题目,统计每位数都不相同的算法
- DBGrid的问提,急!!!!
- RE:[Fatal Error] Project1.dpr(5): Internal error: URW3414是什么错?
- 花了四五个小时才搞定不需要额外控件的XP风格界面和Listview问题,paint...
- 能通过internet网访问SQL SERVER吗?
- intpower函数做什么用的??
- 菜鸟问题 请高手指点
- 问一下,delphi有没有vb哪个chrw哪样的函数?!
- 怎么删除显示在DBGrid上空白行?
- 谁知道一个叫做“标记没有引用存储”的错误??
- 哪位老大碰到过这样的情意?
- 如何查找局域网内的MS SQL2000数据库主机名
adocommand根本没有active 和 close ;有人知道ADOCommand.Parameters.ParseSql(STRSQL,True)这句怎么用吗?
FADORemoteCon.BeginTrans;
try
Off := FQueryLocal.FieldByName('OFFICE').AsString;
Sty := FQueryLocal.FieldByName('STYLE').AsString;
DBStr := 'insert into ' + Off + Sty
+'(TIME,TRKGRP,CFG,MANTBUSY,TOTAL_USAGE,TOTAL_PC,OUT_USAGE,'
+'IN_USAGE,OUT_PC,IN_PC,OUT_ANS_PC,OUT_ABAND_PC,IN_ANS_PC,'
+'IN_ABAND_PC,ATB_USAGE,ATB_PC,OVERFLOWPC,SEIZ_FAIL_PC,MAX_USED,'
+'MIN_USED,NOW_USED) '
+'values(:TI,:TRK,:CFG,:MB,:TU,:TP,:OU,:IU,:OP,:IP,:OAP,:OABP,:IAP,:IABP,'
+':AU,:AP,:OV,:SFP,:MAU,:MIU,:NU)';
FADORemoteCommand.CommandText := DBStr; FADORemoteCommand.Parameters.ParamByName('TI').Value := FQueryLocal.FieldByName('TIME').AsDateTime;
FADORemoteCommand.Parameters.ParamByName('TRK').Value := FQueryLocal.FieldByName('TRKGRP').AsInteger;
FADORemoteCommand.Parameters.ParamByName('CFG').Value := FQueryLocal.FieldByName('P1').AsInteger;
FADORemoteCommand.Parameters.ParamByName('MB').Value := FQueryLocal.FieldByName('P2').AsInteger;
FADORemoteCommand.Parameters.ParamByName('TU').Value := FQueryLocal.FieldByName('P3').AsInteger;
FADORemoteCommand.Parameters.ParamByName('TP').Value := FQueryLocal.FieldByName('P4').AsInteger;
FADORemoteCommand.Parameters.ParamByName('OU').Value := FQueryLocal.FieldByName('P5').AsInteger;
FADORemoteCommand.Parameters.ParamByName('IU').Value := FQueryLocal.FieldByName('P6').AsInteger;
FADORemoteCommand.Parameters.ParamByName('OP').Value := FQueryLocal.FieldByName('P7').AsInteger;
FADORemoteCommand.Parameters.ParamByName('IP').Value := FQueryLocal.FieldByName('P8').AsInteger;
FADORemoteCommand.Parameters.ParamByName('OAP').Value := FQueryLocal.FieldByName('P9').AsInteger;
FADORemoteCommand.Parameters.ParamByName('OABP').Value := FQueryLocal.FieldByName('P10').AsInteger;
FADORemoteCommand.Parameters.ParamByName('IAP').Value := FQueryLocal.FieldByName('P11').AsInteger;
FADORemoteCommand.Parameters.ParamByName('IABP').Value := FQueryLocal.FieldByName('P12').AsInteger;
FADORemoteCommand.Parameters.ParamByName('AU').Value := FQueryLocal.FieldByName('P13').AsInteger;
FADORemoteCommand.Parameters.ParamByName('AP').Value := FQueryLocal.FieldByName('P14').AsInteger;
FADORemoteCommand.Parameters.ParamByName('OV').Value := FQueryLocal.FieldByName('P15').AsInteger;
FADORemoteCommand.Parameters.ParamByName('SFP').Value := FQueryLocal.FieldByName('P16').AsInteger;
FADORemoteCommand.Parameters.ParamByName('MAU').Value := FQueryLocal.FieldByName('P17').AsInteger;
FADORemoteCommand.Parameters.ParamByName('MIU').Value := FQueryLocal.FieldByName('P18').AsInteger;
FADORemoteCommand.Parameters.ParamByName('NU').Value := FQueryLocal.FieldByName('P19').AsInteger; FADORemoteCommand.Execute;
Except FADORemoteCon.RollbackTrans;
DataSyncFail := True;
FQueryLocal.Close;
FADORemoteCon.Connected := false;
FADOLocalCon.Connected := false;
Exit;
End;
应该不会出错,我刚试了一下你单步调试一下看看。另外,楼上指出的是
FADORemoteCon.connection.open;
先让它的连接激活
FADORemoteCon在外边只是定义了,肯定没有其他的地方用到
只在线程里才用到得,水连天兄弟 ,有办法吗〉?谢谢了
其中的FADORemoteCon是在线程create时通过参数传递进去的
FADORemoteCon只在线程里用。其他的地方没有用过的