Recent

Author Topic: Empty DBGrid...  (Read 6277 times)

bungayst

  • New Member
  • *
  • Posts: 15
Empty DBGrid...
« on: May 02, 2013, 08:09:03 pm »
I've been spending a disproportionate amount of time trawling through the forum looking for an answer, this is a pretty simple (or at least it should be) example based on stuff I've done in the past with GAMBAS and VB and some tutorial code for FreePascal from SF. I'll keep hammering on it but sure would appreciate someone with more experience than me would have a peek at the attached project.


  I have connected to the server, executed SQL, and verified that there are 10 records in the Datasource, but the Grid remains quite blank.

Some particulars of my environment.
  Debian 6.0
  Lazarus 0.9.2.28-12 (from Debian repo)
  MySQL 5.0




« Last Edit: May 02, 2013, 09:27:57 pm by bungayst »


bungayst

  • New Member
  • *
  • Posts: 15
Re: Empty DBGrid...
« Reply #2 on: May 02, 2013, 08:42:31 pm »
Yup, been there, done that. I've been through most of those and they were non-helpful. Results are being returned, just nothing gets in the grid. Have a look at the project source.

geno

  • Full Member
  • ***
  • Posts: 198
Re: Empty DBGrid...
« Reply #3 on: May 02, 2013, 08:59:33 pm »
Quote
Have a look at the project source.

The source code file (mysqlexample1.pas) was not included in your tar file.

  regards,
     geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

bungayst

  • New Member
  • *
  • Posts: 15
Re: Empty DBGrid...
« Reply #4 on: May 02, 2013, 09:25:32 pm »
Thanks for looking Geno! Here's the tarball, with the previously missing pascal source added.I had done a "Save Project As" and placed it in it's own folder.. the .pas file apparently didn't follow. The modified tarball attachment has been re-attached to the original posting.
« Last Edit: May 02, 2013, 09:29:32 pm by bungayst »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Empty DBGrid...
« Reply #5 on: May 02, 2013, 10:01:40 pm »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

bungayst

  • New Member
  • *
  • Posts: 15
Re: Empty DBGrid...
« Reply #6 on: May 02, 2013, 10:37:10 pm »
  Thanks BigChimp. Yes, I have seen these. I have the items connected as they are described and that's why I've been pulling my hair out.  As I said in the first post, the Datasource is getting results, I do see a record count, I do see field names, I have checked two ways, by looking at the Datasource directly

DataSource1.DataSet.RecordCount)

and by looking at the datasource as linked to by the grid

DBGrid1.DataSource.DataSet.RecordCount)

  Still nothing visible in the grid. *sigh*. Perhaps I am not seeing the forest for the trees, can you have a look at the project?

geno

  • Full Member
  • ***
  • Posts: 198
Re: Empty DBGrid...
« Reply #7 on: May 03, 2013, 12:58:03 am »
Due to my personal limitations, I am having a bit of trouble with your example program; the form is not being displayed in the IDE.  I am certain it is because it is saved as a resource (.lrs) as opposed to a regular form (.lfm)  I assume it might be because you are using an older version of Lazarus (0.9.28); I cannot say because I am by no means an expert here. 

But, if I am not mistaken, the SQLQuery1.Close in the try..finally block may be your culprit; closing this would clear the grid.

  regards,
    geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

bungayst

  • New Member
  • *
  • Posts: 15
Re: Empty DBGrid... SOLVED
« Reply #8 on: May 03, 2013, 04:16:07 am »
  Spot on Geno. The grid never gets a chance to display the data before the result set is cleared. The sample code I used had that close in the try finally block. I'm going to upgrade to 1.0.8 on my Fedora 14 box and soldier on.
 
  Thank you very much for your insight. I look forward to being able to return the favor to others as I dust off my Pascal knowledge and update it to the OO environment of today.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Empty DBGrid... SOLVED
« Reply #9 on: May 03, 2013, 08:44:47 am »
  Thank you very much for your insight. I look forward to being able to return the favor to others as I dust off my Pascal knowledge and update it to the OO environment of today.
Glad it works, thanks for posting that and good luck learning ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018