Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   DB-Aware (http://www.delphipages.com/forum/forumdisplay.php?f=5)
-   -   [SMDBGrid] "No data to display"? (http://www.delphipages.com/forum/showthread.php?t=196572)

fredtheman 06-01-2008 03:39 AM

[SMDBGrid] "No data to display"?
 
Hello

(since newsgroups.borland.com has been out of commission for several hours ("Connection refused", followed by 502 Cannot connect to the NNTP server, connect error 10061"), I figured I could ask in a web forum instead.)

I'd like to give SMDBGrid a shot, but it remains hopelessly empty with "No data to display", and I haven't examples in either its Yahoo group or through Google.

Here's the code using Aducom's wrapper to use an SQLite database (DB + Query). Although SMDBGrid is set to a DataSource, which itself is connected to the Query which successfully fills the ListBox... still nothing in the SMDBGrid1 widget:

=======
procedure TForm2.FormCreate(Sender: TObject);
var
col, row : Integer;
begin
with ASQLite3DB1 do begin
DefaultDir := ExtractFileDir(Application.ExeName);
Database := 'db.sqlite';
Open;

SQLite3_ExecSQL('CREATE TABLE IF NOT EXISTS products (id integer primary key, name TEXT)');
SQLite3_ExecSQL('INSERT INTO products (id, name) VALUES (NULL,"test")');
end;

DataSource1.DataSet := ASQLite3Query1;
SMDBGrid1.DataSource := DataSource1;
//No trace of an .Open or .Activate method

With ASQLite3Query1 do begin
Connection := ASQLite3DB1;

SQL.Text := Format('SELECT %s FROM products',['products.*']);
Open;

//Grid says "No data to display"
//SMDBGrid1.Enabled := True;
//SMDBGrid1.Update;
//SMDBGrid1.Show;
//SMDBGrid1.Refresh;

First;
while not Eof do begin
for col := 0 to Fields.Count - 1 do begin
ListBox1.Items.Add(Fields[col].AsString);
end;
Next;
end;

Close;
end;

ASQLite3DB1.Close;

end;
=======

Any idea what I'm missing?

Thank you.

mshkolnik 06-01-2008 11:13 AM

RE: [SMDBGrid]
 
You closed the dataset and as result, you don't see the records in grid.
Just remove the Close command

With best regards, Mike Shkolnik
http://www.scalabium.com


All times are GMT. The time now is 04:10 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.