كيف يتم حل مشكلة الخطأ الناتج بعد اغلاق البرنامج رسالة access violation address
#7
[img=909x627][صورة: 328564630.jpg][/img]

كود :
procedure TForm12.Button17Click(Sender: TObject); var f1,s,ss,sss,nn, mm:string; am,wa,m,m1,i,ii,iii,o1,o2:integer;  t:array  of integer;     label test; begin   with datamodule2 do begin     cspan2.Close;     recherchedoh1.Close;     recherchedoh.Close;   end; button17.Enabled:=false;      with datamodule2 do begin          f1:=FileOpenDialog1.FileName;           for i:=length(f1) downto 0 do begin               if f1[i]='\' then begin               f1:=copy(f1,i+1,length(f1)) ;               end;           end;          //-----refrech maxs----------            gg.First;         for i:=0 to gg.RecordCount-1 do begin            //-----------------POUR AFIICHIER TOUS LES ENCORE---------------------------------------                    pre0.Close;                    pre0.SQL.Clear;                    s:=' select tchak.code_cs as REFERENCE,ccp.code_ccp as CCP,ccp.cle_ccp as Clé,nom_cl as Nom,prenom_cl as Prénom,adres_cl as Adresse,telephon_cl as Téléphon,date_k as Date_Debut ';                    s:=s+',pri_men_si as Prix,moi_men_si as Mois,tchak.code_p as N_panier,signalement.code_si,client.code_cl,code_d,tchak.code_k';                    s:=s+' from signalement,client,ccp,tchak ';                    s:=s+' where   client.code_cl=ccp.code_cl and signalement.code_cl=client.code_cl and signalement.code_si=tchak.code_si and signalement.code_ccp='''+dbgrid7.DataSource.DataSet.FieldByName('Champ2').AsString+'''';                    s:=s+'  group by tchak.code_p order by date_k desc';                    pre0.SQL.Add(s);                    pre0.Open;           if pre0.RecordCount-1>0 then begin                   if gg.FieldByName('champ03').AsInteger>0 then begin                    o1:=gg.FieldByName('champ03').AsInteger;                       pre0.First;                      SetLength(t,pre0.RecordCount-1);                    for iii:=0 to pre0.RecordCount-1  do begin                          //--------hna djate wila kanet date_acc< date_relvi;-------------                       //----date_k<gg.FieldByName('champ01').asdate;                       if (o1-pre0.FieldByName('Prix').AsInteger>0) and (iii<pre0.RecordCount-1) then begin                            //---verifier la date  a ce que petite de date d'acciptation------------                        if strtodate(formatdatetime('dd/mm/yy',pre0.FieldByName('Date_Debut').AsDateTime))>strtodate(formatdatetime('dd/mm/yy',gg.FieldByName('champ1').AsDateTime)) then begin                        t[iii]:=0;                        pre0.Next;                         goto test;                       end;                      t[iii]:=pre0.FieldByName('Prix').AsInteger;                      o1:=o1-pre0.FieldByName('Prix').AsInteger;                     end else begin                           if strtodate(formatdatetime('dd/mm/yy',pre0.FieldByName('Date_Debut').AsDateTime))<strtodate(formatdatetime('dd/mm/yy',gg.FieldByName('champ1').AsDateTime)) then begin                           t[iii]:=o1;                           o1:=0;                           end;                   test: end;                     pre0.Next;             end;                 end;           end;               pre0.First;            //-------------------------------END--------------------------------------------------------------              if pre0.RecordCount=1 then begin                  //-----------------------INSERT RELVI----------------------------------------------------------------                   maxs0.Refresh;                   maxs01.Refresh;                   m:=maxs0.FieldByName('id').AsInteger+1;                   m1:=maxs01.FieldByName('id').AsInteger+1;                  //---------------------insertion sure CHEQUE----------------------                    chqi2.close;                    chqi2.SQL.Clear;                    chqi2.SQL.Add('insert into cheque values('''+inttostr(m)+''','''+ pre0.FieldByName('code_k').AsString+''','''+dbgrid7.DataSource.DataSet.FieldByName('Champ03').AsString+''','''+formatdatetime('mmm/yyyy',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''',''Enc'',''1'')');                    chqi2.ExecSQL;                    chqi3.close;                    chqi3.SQL.Clear;                    chqi3.SQL.Add(' insert into prelavment values('''+inttostr(m1)+''','''+pre0.FieldByName('code_k').AsString+''','''+formatdatetime('yyyy-mm-dd',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''','''+''+''','''+inttostr(m)+''','''+f1+''')');                    chqi3.ExecSQL;                    //---------------------------------------------------------------------------------------------------------              end;              if pre0.RecordCount>1 then begin                   for ii :=0 to pre0.RecordCount-1 do begin                       if t[ii]<>0 then  begin                         //-----------------------INSERT RELVI----------------------------------------------------------------                          maxs0.Refresh;                          maxs01.Refresh;                       m:=maxs0.FieldByName('id').AsInteger+1;                       m1:=maxs01.FieldByName('id').AsInteger+1;                         //---------------------insertion sure CHEQUE----------------------                       chqi2.close;                       chqi2.SQL.Clear;                       chqi2.SQL.Add('insert into cheque values('''+inttostr(m)+''','''+ pre0.FieldByName('code_k').AsString+''','''+t[ii].ToString+''','''+formatdatetime('mmm/yyyy',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''',''Enc'',''1'')');                       chqi2.ExecSQL;                       chqi3.close;                       chqi3.SQL.Clear;                       chqi3.SQL.Add(' insert into prelavment values('''+inttostr(m1)+''','''+pre0.FieldByName('code_k').AsString+''','''+formatdatetime('yyyy-mm-dd',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''','''+''+''','''+inttostr(m)+''','''+f1+''')');                       chqi3.ExecSQL;                       end;                       if t[ii]=0 then  begin                         //-----------------------INSERT RELVI----------------------------------------------------------------                          maxs0.Refresh;                          maxs01.Refresh;                       m:=maxs0.FieldByName('id').AsInteger+1;                       m1:=maxs01.FieldByName('id').AsInteger+1;                         //---------------------insertion sure CHEQUE----------------------                       chqi2.close;                       chqi2.SQL.Clear;                       chqi2.SQL.Add('insert into cheque values('''+inttostr(m)+''','''+ pre0.FieldByName('code_k').AsString+''','''+pre0.FieldByName('Prix').AsString+''','''+formatdatetime('mmm/yyyy',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''',''IMP'',''0'')');                       chqi2.ExecSQL;                       chqi3.close;                       chqi3.SQL.Clear;                       chqi3.SQL.Add(' insert into prelavment values('''+inttostr(m1)+''','''+pre0.FieldByName('code_k').AsString+''','''+formatdatetime('yyyy-mm-dd',strtodate(dbgrid7.DataSource.DataSet.FieldByName('Champ1').AsString))+''','''+''+''','''+inttostr(m)+''','''+f1+''')');                       chqi3.ExecSQL;                       end;                     //---------------------------------------------------------------------------------------------------------                     pre0.Next;                   end;              end;            for iii:= 0 to pre0.RecordCount-1 do begin             setlength(t,0);            end;            gg.Next;        end;      end;      showmessage('A été terminé avec succès'); end;

كود :
procedure TForm12.Image3Click(Sender: TObject); var i, ii, n, m,wa: Integer; s,ss,sss,nn, mm: string;  am:integer; begin timer1.Enabled:=false; timer2.Enabled:=false; timer3.Enabled:=false; timer4.Enabled:=false; timer5.Enabled:=false;       with datamodule2 do begin      ADOConnection1.Connected:=false;      ADOConnection10.Connected:=false;      end;         edit7.Clear;        maskedit1.Clear;        combobox2.Text:='';        edit5.Clear;        edit6.Clear;          edit11.Clear; s:='';     with datamodule2 do begin            recherchedoh.Close;            recherchedoh.SQL.Clear;            s:=s+'select  signalement.code_ccp CCP, client.nom_cl Nom,client.prenom_cl Prénom,client.date_nis_cl Date_naissance,signalement.date_si Date_Signalement,signalement.type_si Type_SI,date_k Date_ACC, ';             s:=s+' tchak.code_k,tchak.chek_po_cs,tchak.chek_mo_cs,tchak.code_cs,tchak.code_si,tchak.code_p,signalement.code_d ,signalement.code_cl ,signalement.commentair,signalement.moi_men_si,signalement.pri_men_si ';            s:=s+', ccp.cle_ccp,client.adres_cl,client.telephon_cl,client.fonc ';            s:=s+' ,nom_d Magasin,adres_d,mirie_d,wilaya_d ';            s:=s+' from depo,tchak,signalement,ccp,client where   signalement.code_d=depo.code_d and tchak.code_si=signalement.code_si and signalement.code_ccp=ccp.code_ccp and ccp.code_cl=client.code_cl and code_p = '''+ edit4.Text + '''';            recherchedoh.SQL.Add(s);            recherchedoh.Open;      ts.Caption:=recherchedoh.FieldByName('Type_SI').AsString;      mc.Caption:=recherchedoh.FieldByName('moi_men_si').AsString;      pc.Caption:=recherchedoh.FieldByName('pri_men_si').AsString;      //Memo1.Text:=DBGrid1.DataSource.DataSet.FieldByName('commentair').AsString;      edit3.Text:=recherchedoh.FieldByName('code_cl').AsString;      Label19.Caption:=recherchedoh.FieldByName('Nom').AsString;      Label10.Caption:=recherchedoh.FieldByName('Prénom').AsString;      Label11.Caption:=recherchedoh.FieldByName('Date_naissance').AsString;      Label12.Caption:=recherchedoh.FieldByName('adres_cl').AsString;      Label13.Caption:=recherchedoh.FieldByName('telephon_cl').AsString;      Label14.Caption:=recherchedoh.FieldByName('fonc').AsString;      edit19.Text:=recherchedoh.FieldByName('CCP').AsString;      Label17.caption:=recherchedoh.FieldByName('cle_ccp').AsString;      Label31.Caption:=recherchedoh.FieldByName('Magasin').AsString;      label21.Caption:=recherchedoh.FieldByName('Code_p').AsString;      edit5.Clear;      edit6.Text:=recherchedoh.FieldByName('code_k').AsString;      edit7.Text:=recherchedoh.FieldByName('pri_men_si').AsString;      cl.Caption:=recherchedoh.FieldByName('Code_cs').AsString;      cp.Caption:=recherchedoh.FieldByName('chek_po_cs').AsString;      cm.Caption:=recherchedoh.FieldByName('chek_mo_cs').AsString;      da.Caption:= formatdatetime('dd/mm/yyyy',recherchedoh.FieldByName('Date_ACC').AsDateTime);      ss:='';            recherchedoh1.Close;            recherchedoh1.SQL.Clear;             ss:=ss+' select verse_chek Versement,date_pr Date_ver ,code_enc Encassement,termi_pr Terminer,nom_f Fichier,cheque.code_chek,cheque.code_k,ok_chek,code_pr ';             ss:=ss+' from cheque,prelavment';             ss:=ss+' where cheque.code_chek=prelavment.code_chek and cheque.code_k=prelavment.code_k and cheque.code_k ='''+recherchedoh.FieldByName('code_k').AsString+'''';            recherchedoh1.SQL.Add(ss);            recherchedoh1.Open;           //----------------------------------------------------------------------  

مكملة الكود
كود :
                     wa:=0;                        tv.Caption:='0';            recherchedoh1.First;           for am := 0 to recherchedoh1.RecordCount-1 do begin             if recherchedoh1.FieldByName('ok_chek').AsString='1' then begin             tv.Caption:=inttostr(strtoint(tv.Caption)+(recherchedoh1.FieldByName('Versement').AsInteger));            end else wa:=wa+1;            if (recherchedoh1.RecordCount-1=am) and (recherchedoh1.FieldByName('Terminer').AsString='oui') then begin                         timer3.Enabled:=true;             end else begin                timer3.Enabled:=false;                image4.Visible:=false;             end;           recherchedoh1.Next;           end;            recherchedoh1.First;            //-----------------------------------------------------------------           recherchedoh1.FieldByName('code_chek').Visible:=false;           recherchedoh1.FieldByName('code_k').Visible:=false;           recherchedoh1.FieldByName('ok_chek').Visible:=false;           recherchedoh1.FieldByName('code_pr').Visible:=false;              sss:='';            with datamodule2 do begin           cspan2.Close;           cspan2.SQL.Clear;           sss:=sss+' select n_p, stock.code_pr Code_barr,refe_pr Référence,Desig_pr Désignation,prix_p Prix_vent,nom_f Fournisseur,nom_d Magasin,qte_p QTE,type_ver_p Type_ver';           sss:=sss+' from panier INNER JOIN stock on stock.code_s=panier.code_s and code_p='''+recherchedoh.FieldByName('Code_p').AsString+''' INNER join depo on stock.code_d=depo.code_d inner join preduit on stock.code_pr=preduit.code_pr';           sss:=sss+'  inner join fernuseur on stock.code_f=fernuseur.code_f';           sss:=sss+' ORDER BY `panier`.`n_p` ASC';           cspan2.SQL.Add(sss);           cspan2.Active:=true;                tp.Caption:='0';                cspan2.First;              for am := 0 to cspan2.RecordCount-1 do begin                 tp.Caption:=inttostr(strtoint(tp.Caption)+cspan2.FieldByName('Prix_vent').AsInteger*cspan2.FieldByName('QTE').AsInteger) ;                   cspan2.Next;              end;                cspan2.First;           end;                  // ------------test line big string-------------------------------------------------             //---------variable--------  var i, ii, n, m: Integer; nn, mm: string;                          for i := 0 to DBGrid1.Columns.Count - 1 do  begin                             with DBGrid1.DataSource do begin                                 DataSet.first;                                  m := length(DataSet.Fields[i ].AsString);                                  mm := DataSet.Fields[i ].AsString;                                  DataSet.next;                             for ii := 0 to DataSet.RecordCount do begin                                   if m <= length(DataSet.Fields[i ].AsString) then begin                                         m := length(DataSet.Fields[i].AsString);                                         mm := DataSet.Fields[i ].AsString;                                   end;                                  DataSet.next;                             end;                           end;                       if DBGrid1.Canvas.TextWidth(DBGrid1.Columns[i].Title.Caption) <=  DBGrid1.Canvas.TextWidth(mm) then begin                               DBGrid1.Columns[i].width := 5 + DBGrid1.Canvas.TextWidth(mm);                       end else begin                             DBGrid1.Columns[i].width := 5 + DBGrid1.Canvas.TextWidth                             (DBGrid1.Columns[i].Title.Caption);                           end;                      end;                            // ------------test line big string-------------------------------------------------             //---------variable--------  var i, ii, n, m: Integer; nn, mm: string;                          for i := 0 to stringgrid1.ColCount - 1 do  begin                               m:=0;                               mm:='';                             for ii := 0 to stringgrid1.RowCount -1 do begin                                   if m <= length(stringgrid1.Cells[i,ii]) then begin                                         m := length(stringgrid1.Cells[i,ii]);                                         mm := stringgrid1.Cells[i,ii];                                   end;                             end;                              if stringgrid1.Canvas.TextWidth(stringgrid1.Cells[i,0]) <=  stringgrid1.Canvas.TextWidth(mm) then begin                                stringgrid1.ColWidths[i]  := 10 + stringgrid1.Canvas.TextWidth(mm);                              end else begin                                        stringgrid1.ColWidths[i] := 10+stringgrid1.Canvas.TextWidth(stringgrid1.Cells[i,0]);                                       end;                          end;   // ----------------------------------------------------------------------------------------------------------------                        end;       if w.FieldByName('code_w').AsInteger<=wa then timer1.Enabled:=true else begin       timer1.Enabled:=false;       image1.Visible:=false;       end;    end;       re.Caption:=inttostr(strtoint(tp.Caption)-strtoint(tv.Caption)); end;
الرد


الردود في هذا الموضوع
RE: كيف يتم حل مشكلة الخطأ الناتج بعد اغلاق البرنامج رسالة access violation address - بواسطة merzoug2020 - 13-08-2017, 01:27 AM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم