A
Adnil
Unregistered / Unconfirmed
GUEST, unregistred user!
使用模仿原生ado对象,想模仿TAdoConnection的GetTableNames方法,出现错误,
请大家看看。
var
FRecordSetObject: _Recordset;
FConnectionObject: _Connection;
FConnectionObject := CreateoleObject('adodb.connection') as _Connection;
fconnectionobject.ConnectionString := format(MDB_CONN_STR, ['E:/test.mdb']);
fconnectionobject.CursorLocation := adUseServer;
fconnectionobject.Open('', '', '', 0);
FRecordSetObject := FConnectionObject.OpenSchema(adSchemaTableConstraints, EmptyParam, EmptyParam);
while not FRecordSetObject.EOF do
begin
if FRecordSetObject.Fields['TABLE_TYPE'].Value = 'TABLE' then //这里出现错误
ComboBox1.Items.Add(FRecordSetObject.Fields['TABLE_NAME'].Value);
FRecordSetObject.MoveNext;
end;
FRecordSetObject.Close;
FRecordSetObject := nil;
错误信息为:EOleException: Item cannot be found in the collection corresponding to the requested name or ordinal.
难道根据字段名来取字段值不行吗?
请大家看看。
var
FRecordSetObject: _Recordset;
FConnectionObject: _Connection;
FConnectionObject := CreateoleObject('adodb.connection') as _Connection;
fconnectionobject.ConnectionString := format(MDB_CONN_STR, ['E:/test.mdb']);
fconnectionobject.CursorLocation := adUseServer;
fconnectionobject.Open('', '', '', 0);
FRecordSetObject := FConnectionObject.OpenSchema(adSchemaTableConstraints, EmptyParam, EmptyParam);
while not FRecordSetObject.EOF do
begin
if FRecordSetObject.Fields['TABLE_TYPE'].Value = 'TABLE' then //这里出现错误
ComboBox1.Items.Add(FRecordSetObject.Fields['TABLE_NAME'].Value);
FRecordSetObject.MoveNext;
end;
FRecordSetObject.Close;
FRecordSetObject := nil;
错误信息为:EOleException: Item cannot be found in the collection corresponding to the requested name or ordinal.
难道根据字段名来取字段值不行吗?