SELECT *
FROM Candidate
WHERE Candidate.Username = CurrentUser
CurrentUser是一个全局变量(串),后者从登录的用户名。当我尝试使用带有TDBGrid的SQLQuery时,出现错误,参数CurrentUser没有默认值。参数没有默认值,SQL查询不起作用
unit UntVar;
interface
Var Currentuser:String;
implementation
end.
代码为全局变量。
CurrentUser := EdtUser.Text;
currentuser获取值时的代码。
这可能会发生,是因为你没有定义'CurrentUser',并试图把它给查询。 – Alexander
因此,我必须先给Currentuser一个值,然后才能在查询中使用它。 – user3324069