Witam
Od dłuższego czasu poszukuję procedury, która załadowałaby do Stringgrida dane z bazy danych ( tabeli ) typu postgresql. Chodzi głownie o połączenie Bazy danych ze Stringgridem. Proszę tylko nie proponować DBgrida. Jeżeli ma ktoś pomysł to bardzo proszę o przekazanie na forum. Dla przykładu podaję kod ładowania bazy MSAcess niestety nie jestem zainteresowany tą bazą. Ale jak komuś przyda się ta procedura to bardzo proszę.
procedure TForm1.Button1Click(Sender: TObject);
const
InsertSQL = 'INSERT INTO Countries (Name) VALUES (?);';
var
ID, r: Integer;
NewCountryName: String;
Stmt:
begin
NewCountryName := '';
if InputQuery('Insert', 'Enter new country name:', NewCountryName) then
begin
{ Prepare a insert statement. }
Stmt := FDatabase.Prepare16(InsertSQL);
try
{ We bind all columns as strings. DISQLite3 will convert them to
integers or floats as appropriate. }
Stmt.Bind_Str16(1, NewCountryName);
{ Step once to execute statement and insert data. }
Stmt.Step;
{ Retrieve the RowID of the newly inserted record. }
ID := FDatabase.LastInsertRowID;
{ Add the new country to the StringGrid. Set the name only and
leave other columns empty. }
r := StringGrid.RowCount;
StringGrid.RowCount := r + 1;
SetGridRow(r, ID, NewCountryName);
StringGrid.Row := r;
finally
Stmt.Free;
end;
end;
end;
// wywołanie procedury pod battonem
LoadFromFD(StringGrid1, '.\CARS.MDB' , 'CARS');
A teraz o ile ktoś może podesłać procedurę wraz z wywołaniem będę bardzo wdzięczny. Proszę pamiętać o tym żeby dotyczyło Postgresql i Stringgrida.
Z góry dziękuję za pomoc.
Dłuższy