![]() |
|
أخطأ في الكود الاتصال بMS SQL Server يعمل مرة ويفشل المرة الثانية - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15) +--- الموضوع : أخطأ في الكود الاتصال بMS SQL Server يعمل مرة ويفشل المرة الثانية (/showthread.php?tid=7688) |
أخطأ في الكود الاتصال بMS SQL Server يعمل مرة ويفشل المرة الثانية - merzoug2020 - 04-04-2016 كود : procedure TForm1.Button1Click(Sender: TObject);
const
ConnString =
'Provider=SQLOLEDB.1;Persist Security Info=False;' +
'User ID=%s;Password=%s;Data Source=%s;Use Procedure for Prepare=1;' +
'Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;'+
'Tag with column collation when possible=False';
var i:integer;
begin
timer3.Enabled:=false;
if datamodule2.ADOConnection1.Connected=false then begin
datamodule2.ADOConnection1.ConnectionString:='';
datamodule2.ADOConnection1.ConnectionString := Format( ConnString,[edit1.Text,edit2.text,edit3.text]);
datamodule2.ss:=edit1.Text;
datamodule2.ADOConnection1.Connected:=true;
//------------------------------------------------------------------------------------
with datamodule2 do begin
datamodule2.ss:=edit1.Text;
nom01.close;
nom01.SQL.Clear;
nom01.SQL.Add('select * from Intervenant,user01 where Intervenant.code_i = user01.code_i');
nom01.SQL.Add('and user01.name = '+quotedstr(datamodule2.ss));
nom01.Active:=true;
if nom01.RecordCount>0 then begin
connect01.Open;
connect01.Insert;
connect01.FieldByName('code_i').AsString:= nom01.FieldByName('code_i').AsString;
connect01.FieldByName('Nom_Prenom').AsString:=nom01.FieldByName('nom_i').AsString+' '+nom01.FieldByName('prenom_i').AsString;
connect01.FieldByName('icon').AsString:= 'G';
connect01.Post;
end;
connect01.Active:=false;
datamodule2.connect01.Active:=true;
datamodule2.connect01.First;
form1.FREE:= datamodule2.connect01.RecordCount;
for i:=0 to datamodule2.connect01.RecordCount-1 do begin
Lab := TLabel.Create(Self);
lab.Name:='lab'+inttostr(i);
Lab.Parent := Form1;
Lab.Caption := datamodule2.connect01.FieldByName('Nom_Prenom').AsString;
lab.Font.Size:=16;
lab.Font.Style:=[fsbold] ;
lab.Font.Name:='Segoe Print' ;
Lab.Top := (70 +(i*25));
Lab.Left:= 25;
im := timage.Create(self);
Im.Name:='G0'+inttostr(i);
im.Parent := Form1;
im.Picture:=G.Picture;
im.Stretch:=true;
im.Width:=17;
im.Height:=17;
im.Top := (80 +(i*25));
im.Left:= 2;
datamodule2.connect01.Next;
end;
end;
//-----------------------------------------------------------------------------------
button1.Enabled:=false;
button2.Enabled:=true;
end ;
timer3.Enabled:=true;
end;الدخول في المرة الأولى يشتغل 100% بعد دخول في المرة الثانية table connect01 لا توجد فيها سجل وعندا الذهاب إلى sql server تجد السجل لقد سجل بالتمام و في دالفي غير موجود RE: أينا الخطأ في هاذا كود - mourad39 - 05-04-2016 من الأفضل إرفاق ملفات السورس كود للبرنامج لمعرفة رقم السطر الذي به الخطأ ليتم تصحيحه RE: أين الخطأ في هذا الكود - لؤي - 05-04-2016 إغلق الجدول بعد كل ولوج datamodule2.connect01.close RE: أين الخطأ في هذا الكود - merzoug2020 - 05-04-2016 عملت كل الذي تقوله لكن الحل هوا بعد الحفض السجل في connect01 أضفت adoquery في مكان connect01 و عملت select * from connection01 و تضهر كل السجلات الموجودة |