?
Solved

MSSQL field not seen when trying to populate TStringGrid

Posted on 2007-03-20
2
Medium Priority
?
356 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 2000 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

771 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