Strange Problem: Why field can't be Modified with TADODataset

From: Edward Wang (edwardwang_at_qt-asia.com)
Date: 06/24/04


Date: Thu, 24 Jun 2004 14:03:34 +0800

Hello all,

I am using a TADODataset to open a statement from SQL Server 2000, and
encounterd a strange problem:

sSQL: SELECT CLIENT_NAME, AGE, SPACE(50) AS CLIENT_ADDRESS FROM [CLIENT];

    tmpADODataSet := TADODataSet.Create(Application);
    tmpADODataSet.Connection := GetConnection;
    tmpADODataSet.LockType := ltBatchOptimistic;
    tmpADODataSet.CommandText := sSQL;
    tmpADODataSet.Open;

Ok, when I try to change the records like following:

tmpADODataSet.FieldByName('CLIENT_NAME').AsString = 'New Name';

This should be ok, but:

tmpADODataSet.FieldByName('CLIENT_ADDRESS').AsString = 'Address';

This should report an error.

What's the matter? I can do it sucussfully with BDE, but failed in ADO.

Thanks a lot.

Edward



Relevant Pages