Delphi adoquery to determine whether the field exists

Use the ADOQuery data set to operate the database. Generally, use adoquery.fieldbyname('columnName').asString to access the data. If the columnName does not exist, the system will report the error columnName not found. How to judge whether the columnName exists in advance?

  1. Use FieldList.IndexOf to judge, for example: Adoquery.FieldList.IndexOf('columnName') >= 0 means the field exists, <0 means it does not exist

  2. Use FindField to judge, for example: Adoquery.Fields.FindField('columnName')=nil means the field does not exist

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325454480&siteId=291194637