buenos dias compañeros estoy un poco liado con esta situacion, estoy tratando de crear componentes ado y componentes zeus dentro de un hilo de windows, todo al parecer funciona hasta que trato de asignarle la cadena de conexion al componente tadoconnetions en el evento connect de tcp server este es el codigo
Código Delphi
[-]
procedure TFrm_Interfaces.ServerConnect(AThread: TIdPeerThread);
var
NewClient: PClient;
MisComponentes:tmisComponentes;
begin
GetMem(NewClient, SizeOf(TClient));
NewClient.DNS := AThread.Connection.LocalName;
NewClient.Connected := Now;
NewClient.LastAction := NewClient.Connected;
NewClient.Thread :=AThread;
AThread.Data:=TObject(NewClient);
CoInitialize(nil);
MisComponentes := tmisComponentes.Create;
MisComponentes.Conexion := TADOConnection.Create(self);
MisComponentes.Query := TADOQUERY.Create(Self);
MisComponentes.Conexion1 := TZConnection.Create(self);
MisComponentes.Query1 := TZquery.Create(Self);
AThread.Data := @MisComponentes;
try
Clients.LockList.Add(NewClient);
finally
Clients.UnlockList;
end;
Protocol.Lines.Add(TimeToStr(Time)+' The connection to '+NewClient.DNS+' was connected');
end;
procedure TFrm_Interfaces.ServerExecute(AThread: TIdPeerThread);
var
ActClient, RecClient: PClient;
CommBlock, NewCommBlock: TCommBlock;
RecThread: TIdPeerThread;
i, seleccion: Integer;
MisComponentes:tmisComponentes;
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
AThread.Connection.ReadBuffer (CommBlock, SizeOf (CommBlock));
ActClient := PClient(AThread.Data);
ActClient.LastAction := Now;
MisComponentes := tmisComponentes(AThread.Data);
MisComponentes.Conexion.ConnectionString:=cadena; //esta linea es la que causa el problema
MisComponentes.Conexion.loginprompt:=false;
MisComponentes.Conexion.provider:='SQLOLEDB.1';
MisComponentes.Conexion.connected;
MisComponentes.Conexion1.Catalog:= 'lookup';
MisComponentes.Conexion1.Database:= 'cdr';
MisComponentes.Conexion1.HostName:= '192.168.10.3';
MisComponentes.Conexion1.Password:= 'siti270';
MisComponentes.Conexion1.Protocol:= 'mysql-5';
MisComponentes.Conexion1.port:= 3306;
MisComponentes.Conexion1.User:= 'root';
MisComponentes.Conexion1.connect;
MisComponentes.Query.Close;
MisComponentes.Query.Connection:= MisComponentes.Conexion;
MisComponentes.Query.SQL.Text:='select idext, DesTel from pbx_ext where acode=:acode';
MisComponentes.Query.parameters.ParamByName('acode').Value:=CommBlock.acode;
MisComponentes.Query.cursorType := ctStatic;
MisComponentes.Query.open;
MisComponentes.Query1.Connection:=MisComponentes.Conexion1;
MisComponentes.Query1.SQL.Text:='update lookup set allowcalls=:allowcalls, ldesc=:ldesc where code=:code ';
i:=0;
seleccion:=MisComponentes.Query.RecordCount;
MisComponentes.Query.First;
While ido
begin
MisComponentes.Query1.Close;
MisComponentes.Query1.ParamByName('allowcalls').Value:=CommBlock.estado;
MisComponentes.Query1.ParamByName('ldesc').Value:=CommBlock.nombre;
MisComponentes.Query1.ParamByName('code').Value:=MisComponentes.Query1.fieldbyname('idext').Value;
MisComponentes.Query1.ExecSQL;
i:=i+1;
MisComponentes.Query.Next;
end;
Protocol.Lines.Add (TimeToStr(Time)+' The process for '+CommBlock.MyUserName+' was done '); NewCommBlock.Command := 'DIALOG'; NewCommBlock.MyUserName := '[PBX Server]'; NewCommBlock.Msg := 'The process was done '; NewCommBlock.ReceiverName := '[return-to-sender]'; AThread.Connection.WriteBuffer (NewCommBlock, SizeOf (NewCommBlock), true); end;
end;
el error que marca es el siguiente ---------------------------
Debugger Exception Notification
---------------------------
Project interfacesP.exe raised exception class EAccessViolation with message 'Access violation at address 00F2BBA9. Write of address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
alguna idea de por que me de el error o alguna otra sugerencia de como podria crear dichos componentes y manipularlos gracias por cualquier comentario