Incorrect field alias name when using static cursor
Posted: Fri 30 Apr 2010 02:45
The alias name is incorrect when using a constant as column value.
To recreate:
CREATE TABLE TEST (ID INT)
Then use the following code:
varQry := TMSQuery.Create(nil);
varQry.Connection := MSConnection1;
varQry.SQL.Text := 'select 1 as column1, id from test';
//Note: the issue only happens with ctStatic cursor type
varQry.CursorType := OLEDBAccess.ctStatic;
varQry.Open;
//Field[0].FieldName became COLUMN1_1.
//This is incorrect. Should be COLUMN1!
if varQry.FindField('COLUMN1') = nil then
ShowMessage('Field is missing!');
The same code works with ADO using static cursor. E.g.:
varADOQry := TADOQuery.Create(nil);
varADOQry.Connection := ADOConnection1;
varADOQry.CursorType := ADODb.ctStatic;
varADOQry.SQL.Text := 'select 1 as column1, id from test';
varADOQry.Open;
//Field[0].FieldName is COLUMN1 correctly
if varQry.FindField('COLUMN1') nil then
We bought SDAC to replace ADO.
This is a serious showstopper issue for us. Changing cursor type is not an option.
Can this be fixed or worked around somehow?
Regards
Geza Szabo
Senior Software Engineer
To recreate:
CREATE TABLE TEST (ID INT)
Then use the following code:
varQry := TMSQuery.Create(nil);
varQry.Connection := MSConnection1;
varQry.SQL.Text := 'select 1 as column1, id from test';
//Note: the issue only happens with ctStatic cursor type
varQry.CursorType := OLEDBAccess.ctStatic;
varQry.Open;
//Field[0].FieldName became COLUMN1_1.
//This is incorrect. Should be COLUMN1!
if varQry.FindField('COLUMN1') = nil then
ShowMessage('Field is missing!');
The same code works with ADO using static cursor. E.g.:
varADOQry := TADOQuery.Create(nil);
varADOQry.Connection := ADOConnection1;
varADOQry.CursorType := ADODb.ctStatic;
varADOQry.SQL.Text := 'select 1 as column1, id from test';
varADOQry.Open;
//Field[0].FieldName is COLUMN1 correctly
if varQry.FindField('COLUMN1') nil then
We bought SDAC to replace ADO.
This is a serious showstopper issue for us. Changing cursor type is not an option.
Can this be fixed or worked around somehow?
Regards
Geza Szabo
Senior Software Engineer