Solved

MSSQL field not seen when trying to populate TStringGrid

Posted on 2007-03-20
2
348 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now