#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    42
    Rep Power
    2

    Why DBGrid column shows only 40 characters ?


    Why it is showing only first 40 characters of data at Description column from database table at my DBGrid component ?

    Same experience I am getting with DBAdvGrid also it is showing only first 40 characters from Description column of my Database table. Width of the column at DBGrid and DBAdvGrid is also sufficient to show all data, maxsize is also set as 644.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    Originally Posted by ninadgac
    Why it is showing only first 40 characters of data at Description column from database table at my DBGrid component ?

    Same experience I am getting with DBAdvGrid also it is showing only first 40 characters from Description column of my Database table. Width of the column at DBGrid and DBAdvGrid is also sufficient to show all data, maxsize is also set as 644.
    Add the following somewhere after the query is opened.
    Code:
    ...
    MyQuery.First;
    while Not MyQuery.EOF do
    begin
      if Length(MyQuery.FieldByName('Description').AsString) > 40 then
         ShowMessage(MyQuery.FieldByName('Description').AsString;
      MyQuery.Next;
    end;
    If you get the message pop up then you at least know that the DB is returning values that are longer than the 40 characters you are seeing, so the problem is how the DBGrid is showing the data, if you don't get the message, then the DB is not returning the data you are expecting and the problem is in how your query / table are defined.

    Comments on this post

    • ninadgac agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    42
    Rep Power
    2
    Good way to track where the problem , did as told by you it is not returning any message means problem lies at UniQuery / UniTable component (the way it is defined)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    ..
    Last edited by majlumbo; November 18th, 2013 at 09:40 AM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    Originally Posted by ninadgac
    Good way to track where the problem , did as told by you it is not returning any message means problem lies at UniQuery / UniTable component (the way it is defined)
    So next,
    1) are you using a query or a table component? (query is preferable, give you much more control over your result set)
    2) which version of Delphi are you using? (as in, does it support UNICODE? Delphi 2009 and greater...)
    3) which database are you using?
    4) how is the Description field defined within that database?

    Comments on this post

    • ninadgac agrees
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    42
    Rep Power
    2
    1) I tried it with both UniQuery and UniTable, same problem.
    2) Delphi version XE3.
    3) Database :- SQLite
    4) Description field is defined in database as :- description VARCHAR( 40 ) NULL

    Even it is defined as varchar( 40 ) in database it is showing more than 40 almost all characters / data entered.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    42
    Rep Power
    2
    Originally Posted by majlumbo
    So next,
    1) are you using a query or a table component? (query is preferable, give you much more control over your result set)
    2) which version of Delphi are you using? (as in, does it support UNICODE? Delphi 2009 and greater...)
    3) which database are you using?
    4) how is the Description field defined within that database?
    Hats Off, Problem solved by setting varchar (200) or greater.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    Originally Posted by ninadgac
    Hats Off, Problem solved by setting varchar (200) or greater.
    Glad to help...

IMN logo majestic logo threadwatch logo seochat tools logo