Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2008, 03:39 AM
fredtheman fredtheman is offline
Member
 
Join Date: Dec 2004
Posts: 52
Default [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.
Reply With Quote
  #2  
Old 06-01-2008, 11:13 AM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default 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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:44 AM.


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