天
天涯一客
Unregistered / Unconfirmed
GUEST, unregistred user!
unit UQsdate;<br><br>interface<br><br>uses<br> Classes,SysUtils,Math;<br><br>type<br> querysendThread = class(TThread)<br> private<br> { Private declarations }<br> protected<br> procedure sendnumber;<br> procedure Receivedata;<br> procedure query;<br> procedure Execute; override;<br> public<br> constructor create;<br> end;<br><br>implementation<br> uses main,dmpublic,dataDM,publicdata;<br>{ Important: Methods and properties of objects in visual components can only be<br> used in a method called using Synchronize, for example,<br><br> Synchronize(UpdateCaption);<br><br> and UpdateCaption could look like,<br><br> procedure querysendThread.UpdateCaption;<br> begin<br> Form1.Caption := 'Updated in a thread';<br> end; }<br><br>{ querysendThread }<br><br>constructor querysendThread.create;<br>begin<br> inherited create(true);<br> Priority :=tpNormal;<br>// Priority := tpLower;<br>end;<br><br>procedure querysendThread.Execute;<br>var<br>sql2:string;<br>times,showtime,n,j,i,k,b:integer;<br>begin<br><br>FrmMain.Timer2.Enabled :=false;<br>b:=0;<br> sql2:='select time from action_set where loginName='''+yhm+''' and userpassword='''+pass+'''';<br> opendate(data.q4 , sql2);<br>times:=data.q4.fieldbyName('time').AsInteger;<br><br>begin<br> dm.ShuaxingStoredProc.Parameters .ParamByName('@loginName').Value:=yhm ;<br> dm.ShuaxingStoredProc.Parameters.ParamByName('@password').Value:=pass ;<br> dm.ShuaxingStoredProc.Open ;<br><br>with dm.ShuaxingStoredProc do<br> begin<br> first;<br> while not Eof do<br> begin<br> <br> <br> Synchronize(sendnumber) ; //送数<br><br> ExecSQLdate(dm.UPdataADOQuery ,'update RM_def set change=0 where Com_addr='+addr <br> <br> <br> Synchronize(query); //查询<br> <br> <br> <br> Synchronize(Receivedata)<br> <br> ExecSQLdate(dm.UPdataADOQuery ,'update RM_def set showtimes='+inttostr(showTime)+' where com_addr='+FieldByName('Com_addr').AsString);<br> ExecSQLdate(dm.UPdataADOQuery ,'update other set temperature1=0, temperature=0, temperature2=0, urgent=0,air1=0,air2=0,air3=0,Cardtype=0 where com_addr='+addr);<br><br> <br><br> next<br> end;<br> <br>end;<br> dm.ShuaxingStoredProc.Close;<br>FrmMain.Timer2.Enabled :=true;<br><br>end;<br><br>procedure querysendThread.Receivedata;<br>var<br> tep,tep1:byte;<br> paritybit:byte;<br> i,j:integer;<br> TMinute:Extended ;<br> sql,O_sql,sql_Rm,dz:string;<br> sql_so,sql_en:string;<br>begin<br>sql:='update serve set';<br>O_sql:='update other set';<br>sql_Rm:='update RM_def set showtimes=0,comok=1';<br>sql_so:='select Fkey,Door,safe_door,serve,someone from serve_other_view where com_addr=';<br><br> ExecSQLdate(dm.UPdataADOQuery ,sql_en);<br> ExecSQLdate(dm.UPdataADOQuery ,sql);<br> ExecSQLdate(dm.UPdataADOQuery ,O_sql);<br> ExecSQLdate(dm.UPdataADOQuery ,sql_Rm);<br> except<br> exit;<br> end;<br> end;<br><br><br>//------------送数----------------------<br> procedure querysendThread.sendnumber;<br>var<br> sbuf:array[0..20] of byte;<br> paritybit:byte;<br> i:integer;<br>begin<br>sbuf[0]:=85;<br>sbuf[1]:=50;<br>sbuf[2]:=48;<br>sbuf[3]:=49;<br>//取通讯地址 根据房间号找到地址号<br>sbuf[4]:=asc(HexaToDecimal(copy(inttohex(adr,2),1,1)));<br>sbuf[5]:=asc(HexaToDecimal(copy(inttohex(adr,2),2,1)));<br>sbuf[6]:=asc(RM_STA_Tmp);<br>sbuf[7]:=asc(RM_STATUS);<br>sbuf[8]:=48;<br>sbuf[9]:=49;<br>sbuf[10]:=48;<br>sbuf[11]:=asc(hexatodecimal(copy(inttohex(RM_SETTEMP *10,3),1,1)));<br>sbuf[12]:=asc(hexatodecimal(copy(inttohex(RM_SETTEMP*10,3),2,1)));<br>sbuf[13]:=asc(hexatodecimal(copy(inttohex(RM_SETTEMP*10,3),3,1)));<br>sbuf[14]:=56;<br>sbuf[15]:=asc(AirFan);<br>sbuf[16]:=56;<br>sbuf[17]:=asc(AirFan1);<br>paritybit:=sbuf[1];<br>for i:=2 to 17 do<br>paritybit:=paritybit xor sbuf;<br>sbuf[18]:=asc((paritybit and $f0) div 16);<br>sbuf[19]:=asc((paritybit and $f) mod 16);<br>sbuf[20]:=13;<br>FrmMain.ComPort.write(sbuf,Length(sbuf));<br>end;<br><br><br>procedure querysendThread.query;<br>var<br> sbuf:array[0..8]of byte;<br> paritybit:byte;<br>begin<br>sbuf[0]:=85;<br>sbuf[1]:=51;<br>sbuf[2]:=48;<br>sbuf[3]:=48;<br>sbuf[4]:=asc(HexaToDecimal(copy(inttohex(Strtoint(addr),2),1,1)));<br>sbuf[5]:=asc(HexaToDecimal(copy(inttohex(Strtoint(addr),2),2,1)));<br>paritybit:=sbuf[1] xor sbuf[2]xor sbuf[3] xor sbuf[4] xor sbuf[5];<br>sbuf[6]:=asc((paritybit and $f0)div 16);<br>sbuf[7]:=asc(paritybit and $f <br>sbuf[8]:=13;<br>FrmMain.ComPort.write(sbuf,Length(sbuf));<br>end;<br><br>end.<br><br><br>procedure ExecSQLdate(query:Tadoquery;sql:string);<br>begin<br> query.close;<br> query.SQL.Clear;<br> query.SQL.add(sql);<br> query.ExecSQL;<br>end;<br><br>procedure opendate(query:Tadoquery;sql:string);<br>begin<br> query.close;<br> query.SQL.Clear;<br> query.SQL.add(sql);<br> query.Prepared;<br> query.Open;<br>end;<br>请问各位市手,我在使用以上语句调用时什突发情出现"连接占线导致另一个命令"错误<br>并停在ADODB的<br><br> if not Assigned(Recordset) then (第3472行)<br> begin<br> InitializeConnection;<br> InitializeRecordset;<br> Recordset.Open(Source, ActiveConnection,<br> CursorTypeValues[FCursorType], LockTypeValues[FLockType],<br> Integer(CommandTypeValues[CommandType]) + ExecuteOptionsToOrd(ExecuteOptions));<br> while Recordset.State = adStateClosed do<br> try<br> FRecordsetObject := Recordset.NextRecordset(VarRecsAffected);<br> if Recordset = nil then Abort;<br> except<br> DatabaseError(SNoResultSet, Self);<br> end;<br> end else<br> EnableEvents;<br> if (eoAsyncExecute in ExecuteOptions) and ((Recordset.State and adStateExecuting) <> 0) then<br> SetState(dsOpening);<br> inherited OpenCursor(False);<br>end;<br><br><br>请问高手,要怎么样才能很好的解决这个问题,