Solved

MSSQL field not seen when trying to populate TStringGrid

Posted on 2007-03-20
2
353 Views
Last Modified: 2013-11-23
I am populating a TStringGrid with a single row of data from an MS SQL table. It finds the row and gets stuck when looking at a certain field. Delphi claims it does not exist when I run the app.

Below is the code:
procedure TfrmStudentOrders.FormCreate(Sender: TObject);
var
intRow : Integer;
begin
  if Length(frmNewStudentSelect.EditStudentID.Text) > 0 then
  begin
  //If student exists, i'll do all this
    QuerySelectOrders.SQL.Clear;
    QuerySelectOrders.SQL.Add('SELECT * FROM order_details_tbl WHERE student_id = '''+frmNewStudentSelect.EditStudentID.Text+'''');
    QuerySelectOrders.Open;
    StringGridOrders.RowCount := QuerySelectOrders.RecordCount + 1;
    intRow := 1;
    while not QuerySelectOrders.EoF do
    begin
      StringGridOrders.Cells[0,intRow] := QuerySelectOrders.FieldByName('order_id').AsString;
      StringGridOrders.Cells[1,intRow] := QueryselectOrders.FieldByName('date_in').AsString;
      StringGridOrders.Cells[2,intRow] := QueryselectOrders.FieldByName('due_out').AsString;
      StringGridOrders.Cells[3,intRow] := QuerySelectOrders.FieldByName('build_number').AsString;
      StringGridOrders.Cells[4,intRow] := QuerySelectOrders.FieldByName('sherlock_number').AsString;
      StringGridOrders.Cells[5,intRow] := QuerySelectOrders.FieldByName('yellow_number').AsString;
      QuerySelectOrders.Next;
      inc(intRow);
    end
  end
  else
etc...


It claims "build_number" does not exist, and also "yellow_number" and "sherlock_number" do not contain any information, although all 3 do contain data.

They are nvarchar fields.

Any ideas?
0
Comment
Question by:wbstech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 18757590
Are You using BDE?
BDE has problems with nvarchar fields.
I'm no sure if it was ever repaired.
use varchar fields if possible.
If not switch to ADO
0
 
LVL 4

Author Comment

by:wbstech
ID: 18762447
Changed to varchar, problem solved. Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to send memory stream from ics Client To ics server ? 11 180
RESTRequest Parameter 4 54
How to make Sign in, using Clientdataset? 1 33
DBCtrlGrid, Delphi, Scroll 8 59
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question