Solved

MSSQL field not seen when trying to populate TStringGrid

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 88
Strange behavior when a form is closed 6 58
Wincontrol not (correctly) drawn 15 38
Twebbrowser add css to the header 3 25
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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

778 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