Modification DLL

Résolu
vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 - 21 juil. 2017 à 08:56
vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 - 21 juil. 2017 à 10:37
Bonjour,

Je suis en grande détresse. Je ne vois absolument pas comment régler mon problème. (si problème il y a puisque ça marche parfaitement sur une autre application)
Je me connecte à mon serveur SQL de la façon suivante :
try
NorfondTable := TTable.Create(nil);
NorfondTable2 := TTable.Create(nil);
EVENT := TTable.Create(nil);
ADOCO := TAdoConnection.Create(nil);
ADOQuery := TAdoQuery.Create(nil);
ADOCO2 := TAdoConnection.Create(nil);
ADOQuery2 := TAdoQuery.Create(nil);
ADOCOEvent := TAdoConnection.Create(nil);
ADOQueryEvent := TAdoQuery.Create(nil);
except
sleep(100);
end;

Emplacement_Fichier:=Fichier_Ini.ReadString('Variables_globales','Emplacement_EVENT','');
Nom_Table := Fichier_Ini.ReadString('Variables_globales','Nom','');
Catalog := Fichier_Ini.ReadString('Variables_globales','Catalog','');
Nom_Serveur := Fichier_Ini.ReadString('Variables_globales','Nom_Serveur','');
Password := Fichier_Ini.ReadString('Variables_globales','Password','');
User_ID := Fichier_Ini.ReadString('Variables_globales','User_ID','');
AdoQueryEvent.ConnectionString:='Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + User_ID + ';Initial Catalog=' + Catalog + ';Data Source=' + Nom_Serveur;
CommandeSQL := 'Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + User_ID + ';Initial Catalog=' + Catalog + ';Data Source=' + Nom_Serveur;
with AdoCoEvent do Begin
ConnectionString:='Provider=SQLOLEDB.1;Password=' + Password + ';Persist Security Info=True;User ID=' + User_ID + ';Initial Catalog=' + Catalog + ';Data Source=' + Nom_Serveur;
ConnectOptions:=CoAsyncConnect;
OnConnectComplete:=MaConnectComplete;
OnExecuteComplete:=MaConnectionExecuteComplete;
loginPrompt:=False;
Connected:=true;
End;


Les deux fonctions que j'utilise dans mon with sont les suivantes :
procedure TReadWriteDBFile.MaConnectComplete(Connection: TADOConnection;const Error: Adoint.Error; var EventStatus: TEventStatus);
begin
adoCommand1:=TADOCommand.Create(nil);
ConsoleTrace('Activation de la table EVENEMENT (SQL)', DebuggLevel1);
if EventStatus=esErrorsOccured then
Begin
//Une fois DBase supprimer, ajouter ici la partie secours de la base EVENT
ConsoleTrace('Problème d''activation de la table EVENEMENT (SQL). Passage en mode secours.', DebuggLevel1);
End
else
begin
with adoCommand1 do begin
Connection:=adoCo;
ExecuteOptions:=[eoAsyncExecute]+[eoExecuteNoRecords];
Execute;
ConsoleTrace('Activation de la table EVENEMENT (SQL) OK', DebuggLevel1);
end;
end;
end;

procedure TReadWriteDBFile.MaConnectionExecuteComplete(Connection: TADOConnection; RecordsAffected: Integer; const Error:Adoint.Error; var EventStatus: TEventStatus; const Command: _Command;const Recordset: _Recordset);
begin
MessageDlg(IntToStr(RecordsAffected)+' modifications effectués',mtInformation,[mbOK],0);
end;


Le thread plante au moment ou j'utilise cette fonction :

AdoQueryEvent.Last;


Je sais que ça plante à partir de ce point la puisque j'utilise des ConsoleTrace pour écrire dans la console DOS les différents événements rencontrés au cours de l’exécution.

J'aimerais donc savoir pourquoi ça plante à ce moment précis ?

Question bonus : A quoi sert un AdoQuery.Active ? Que fait il exactement ? Que retourne t'il ? (Je ne trouve rien de très intéressant a ce sujet.)

Cordialement.

2 réponses

vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 2
21 juil. 2017 à 09:18
Bon, j'ai peut être trouvé la solution a mon problème et si c'est ce que je pense, j'ai très honte ...
0
vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 2
21 juil. 2017 à 10:20
Du coup, nouveau problème.

Quand j'utilise AdoQuery.Open ou AdoQuery.ExecSQL, ça plante.
J'essaye juste d'utiliser une Requête
Select * From Ma_table
.
Je ne comprend pas, je suis largué total.

Cordialement.
0
vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 2
Modifié le 21 juil. 2017 à 10:21
CommandeSQl := 'if exists (SELECT * From ' + Nom_Table + ');';
ConsoleTrace('if exists (SELECT * From ' + Nom_Table + ');', DebuggLevel1);
AdoQueryEvent.SQL.text := CommandeSQL;
ConsoleTrace('SQL.Text', DebuggLevel1);
AdoQueryEvent.Open;
ConsoleTrace('OPEN', DebuggLevel1);
AdoQueryEvent.SQL.Clear;
ConsoleTrace('SQL.CLEAR', DebuggLevel1);
CommandeSQL := '';
0
vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018 2 > vico8000 Messages postés 287 Date d'inscription lundi 18 janvier 2016 Statut Membre Dernière intervention 14 février 2018
21 juil. 2017 à 10:37
J'ai l'impression que je ne peux exécuter aucune fonction des AdoQuery et AdoConnection. Cela n'est pas restraint à OPEN ou EXECSQL. Rien ne marche. Aurais-je oublié quelques chose ?
0
Rejoignez-nous