Solved

MSSQL field not seen when trying to populate TStringGrid

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Communication Between RC4 Delphi <-> PHP 3 99
Send message from delphi to whatsapp, is it possible? 3 1,139
Mobile Keyboard covers the display of the TMemo 3 78
The line on IDE 4 65
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

932 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

11 Experts available now in Live!

Get 1:1 Help Now