關於delphi SetLength函式一個錯誤,請大家幫忙看看
阿新 • • 發佈:2019-01-27
以下程式碼在delphi 2007編寫 function GetRole(var Roles:array of RRole):Boolean;//獲取所有角色 var sqlstr:string; begin Result:=True; sqlstr:='select * from T_Role'; m_adoQuery.Close; m_adoQuery.SQL.Text:=sqlstr; m_adoQuery.ConnectionString:=m_ConnectionString; try m_adoQuery.Open; m_adoQuery.First; SetLength(Roles,0); while not m_adoQuery.eof do begin SetLength(Roles,Length(Roles)+1); Roles[Length(Roles)-1].RoleCode:=m_adoQuery.FieldByName('RoleCode').AsString; Roles[Length(Roles)-1].RoleName:=m_adoQuery.FieldByName('RoleName').AsString; GetAuthorityFromRole(Roles[Length(Roles)-1].Authoritys); end; m_adoQuery.Close; except Result:=False; m_adoQuery.Close; end;
在編譯的時候提示如下錯誤
[DCC Error] DatabaseFuntion.pas(49): E2008 Incompatible types