Cześć,
mam program kontaktujący się z bazą danych niestety coś świruje, najgorszym problemem jest to że jeśli mam przed wywołaniem procedury wykonującej zapytanie ShowMessage to zapytanie się wykonuje a jak nie mam to się nie wykonuje. Nie mam pojęcia dlaczego.
Oto kod procedury wykonującej zapytanie:
procedure TConnection.DoSQL(sqlquery: string; caption : string = '');
begin
ActionCaption := caption;
SendCommand('SV_DOSQL@'+sqlquery+'@');
end;
procedure TConnection.SendCommand(command: string);
begin
Form1.Logs.Add(FormatDateTime('yyyy.mm.dd,hh:nn', Now)+' Sending: '+command);
//Command := CP2CP(PChar(command), 1250, 28592, 0);
Command := WinToIso(Command);
Command := Form1.Base64Encoder.EncodeString(Command);
Browser.Navigate(ServerName+'request.php?command='+Command);
end;
A to procedura usuwająca element z bazy:
procedure TForm1.MenuItem7Click(Sender: TObject);
var
c,i: integer;
s,d,e,f,q,q1,q2: string;
struct: Integer;
tab: TADCTable;
begin
c := ListView8.SelCount;
if MessageBox(Handle, PChar('Czy chcesz usunąć zaznaczone elementy?'+#13+Format('Ilość zaznaczonych elementów: %d', [c])),
PChar('Usuwanie elementów'), MB_ICONQUESTION or MB_YESNO)=IDNO then exit;
Tab:= TADCTable.Create(self);
s := ''; d:=''; e := ''; f:='';
with ListView8 do
For i:=0 to Items.Count-1 do
if Items[i].Selected then
begin
a:= 'SELECT STRUCT FROM structure';
a:= a + ' WHERE PRIORITY='+IntToStr(Items[i].StateIndex);
server.Server.ExecSQL('plastmet_rd', a);
Tab.GetAtributesFrom(Form1.server.Server.Table);
Tab.First;
struct := Tab.FieldByName('STRUCT').AsInteger;
Tab.Free;
/usuwa z tabeli left_menu
if e='' then
e := e + 'PRIORITY='+IntToStr(Items[i].StateIndex)
else
e := e + ' OR PRIORITY='+IntToStr(Items[i].StateIndex);
f:= 'DELETE FROM left_menu WHERE ';
//usuwa z tabeli structure
if s='' then
s := s + 'PRIORITY='+IntToStr(Items[i].StateIndex)
else
s := s + ' OR PRIORITY='+IntToStr(Items[i].StateIndex);
d:= 'DELETE FROM structure WHERE ';
q:= 'UPDATE left_menu SET PRIORITY=PRIORITY-1';
q:= q + ' WHERE PRIORITY>'+IntToStr(Items[i].StateIndex);
q1:= 'UPDATE structure SET PRIORITY=PRIORITY-1';
q1:= q1 + ' WHERE PRIORITY>'+IntToStr(Items[i].StateIndex);
q2:= 'UPDATE structure SET STRUCT=STRUCT-1';
q2:= q2 + ' WHERE STRUCT>'+IntToStr(struct);
end;
ShowMessage(f+e);
server.DoSQL(f+e);
ShowMessage(d+s);
server.DoSQL(d+s);
ShowMessage(q);
server.DoSQL(q);
ShowMessage(q1);
server.DoSQL(q1);
ShowMessage(q2);
server.DoSQL(q2);
i := 0;
while i<ListView8.Items.Count do
Begin
if ListView8.Items[i].Selected then
ListView8.Items[i].Delete
else Inc(i);
end;
GetPageName;
MessageBox(Handle, PChar('Usunięto zaznaczone obiekty z bazy danych'+#13+Format('Ilość usuniętych obiektów: %d', [c])),
PChar('Obiekty usunięto'), MB_ICONINFORMATION or MB_OK);
end;
Jest może troche choasu ale może jakoś mi pomożecie, bo ja nie jestem zbyt zaawansowana.