Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:51:36+00:00 2026-06-17T18:51:36+00:00

Let’s say I have this table: name varchar(255), quantity integer, value float When I

  • 0

Let’s say I have this table:

name        varchar(255),
quantity    integer,
value       float

When I used this code:

select left(name, 99), quantity, value from table;

But I’ve got all the 255 spaces (by space I mean width length, not the real space chars) on the first column of the dbgrid and the other two fields where away unless I used the scroll bar and my objective was to make scroll bars not necessary.

How do I get this goal correctly? I use Firebird and MySQL.

I can not do this by pascal code nor define it on the Fields object of the table component because this codes comes from many tables as this is a report generator and the first field is not always the same and for each report I have to use a different SQL code.

enter image description here

PLEASE, EVERYBODY READ THE ALL QUESTION BEFORE ANSWERING. THE FIRST 3 ANSWER WHERE WRONG BECAUSE THEY DID NOT CONSIDERED WHAT AS WRITTEN IN THE LAST PARAGRAPH!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:51:38+00:00Added an answer on June 17, 2026 at 6:51 pm

    Since you’ve said you can’t do it on the TField level or in your Delphi code, you can use Trim() or Left(), depending on the database you’re using, on the column to remove the blank spaces you don’t want to display:

    For instance, in many SQL dialects you could use something like:

    SELECT Col1, Col2, Trim(Col3) as Col3 FROM yourtable 
    WHERE somecondition
    

    Some allow this instead:

    SELECT Col1, Col2, Left(Col3, MaxCharWidthAllowed) as Col3 FROM yourtable 
    WHERE somecondition
    

    or

    SELECT Col1, Col2, Substring(Col3, 1, MaxCharWidth) as Col3 FROM yourtable
    

    As a quick test (I don’t have FB, but have SQL Server 2008, so I used it), I created the following test data in SQL Server Management Studio:

    Test data in SSMS

    I then created a new D2007 VCL Forms application, and performed the following steps:

    • Dropped an TADOConnection on the form (ADOConnection1), and set up the connection string to the test data above
    • Dropped two TADOQuery components on the form (ADOQuery1 and ADOQuery2), and set their Connection properties to ADOConnection1
    • Dropped two TDataSource components on the form (DataSource1 and DataSource2) and connected their DataSet properties to the matching ADOQuery1 and ADOQuery2
    • Dropped two TDBGrid components (DBGrid1 and DBGrid2) and set their DataSource properties to the matching DataSource1 and DataSource2.
    • Added SELECT * FROM test to the SQL for ADOQuery1
    • Added SELECT Substring(itemname, 1, 30) as itemname, quantity, value FROM test as the SQL of ADOQuery2. The length of 30 was arbitrarily chosen as being a small enough value to demonstrate the considerably smaller column width.
    • Set ADOConnection1.Connected to True, and set both TADOQuery.Active properties to True.

    The above produced this output (at design time, without ever compiling or running the application), with the top grid being DBGrid1:

    Design-time output of above steps

    As you can see, in DBGrid2, which is connected to ADOQuery2 with the Substring in the SQL, the first column is correctly sized to 30 characters width.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have such MYSQL table for logins: id---name---location---login_date ---------------------------------- 1----mike----usa-----21.08.2012 2----tony----uk------22.08.2012 3----tony----uk------23.08.2012
Let's say I have a table with a Color column. Color can have various
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have the following data frame: > myvec name order_no 1 Amy
Let's say I have this element for displaying the website logo: <div id="web-title"> <a
Let's consider this code: (function(){ var a = {id: 1, name: mike, lastname: ross};
Let's say I have pseudocode like this: main() { BOOL b = get_bool_from_environment(); //get
Let's say I have an actor like this (Using Akka 2.1 with Scala 2.10):
Let me frame it this way.. Say I have an application server running on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.