procedure TMainForm.UniFormCreate(Sender: TObject); begin FDConnection1.Connected:=true; FDQuery_user.Active:=true;
FDQuery_user.SQL.Text:= 'select id,user_name,password from user'; end;
FDQuery1.SQL.Text :='SELECT * FROM user WHERE user_name=:user_name'; FDQuery1.ParamByName('user_name').Value := uniedit1.Text; FDQuery1.Open(); if not FDQuery1.IsEmpty then begin //如果用户名存在 showmessageN( uniedit1.Text+ ' 用户名 已存在'); exit; end; FDQuery1.SQL.Text :='insert into user values(null, :user_name, :password )'; FDQuery1.ParamByName('user_name').AsString := uniedit1.Text; FDQuery1.ParamByName('password').AsString := md5.GetHashString(UniEdit2.Text); FDQuery1.ExecSQL; FDQuery_user.Refresh; // 显示 所有 用户