Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. begin
  2. //Criar e Configurar um query
  3. with TSQLQuery.Create(Nil) do
  4. Try
  5. Try
  6. DataBase := Mainform.aSQLConnection;
  7. Transaction := Mainform.aSQLConnection.Transaction;
  8. SQL.Clear;
  9. SQL.Add('Select * From Departamento Order By DepNum');
  10.  
  11. //Ir buscar os dados
  12. Open;
  13.  
  14. //Preencher a combobox com o número de departamento
  15. while not eof do
  16. begin
  17. cbDepNum.items.add(fieldbyname('DepNum').AsString);
  18. next;
  19. end;
  20.  
  21. //Colocar o primeiro elemento da lista como ativo...
  22. if cbDepNum.Items.Count > 0 then
  23. cbDepNum.ItemIndex:= 0 ;
  24. Finally
  25. if Active then
  26. Close;
  27. Free;
  28. end
  29. //Se alguma coisa funcionou mal...
  30. //... mostrar uma mensagem e...
  31. Except
  32. on E:exception do
  33. begin
  34. ShowMessage(e.message);
  35. end;
  36. end;
  37. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement