Delphi [Trim(), Application.MessageBox(), three-tier database modification]

RAD Studio 10.2 test √


Trim function
function prototype function Trim(const S: string): string; clear the blanks and control characters before and after the string
function prototype function TrimLeft(const S: string): string; remove the blanks and control characters on the left side of the string Clear
function prototype function TrimRight(const S: string): string; Clear the blank and control characters on the right side of the string

Note that the Trim function can only clear the spaces and control characters before and after the string, but not the spaces in the string.


Application.MessageBox() function

// 信息窗口【只有一个确认按钮】
Application.MessageBox('内容不能为空', '提示', MB_OK + MB_ICONINFORMATION);

// 询问窗口【有确认和取消按钮】
case Application.MessageBox('确认提交当前已更改数据?', '提示', MB_OKCANCEL + MB_TOPMOST) of
  IDOK:// 确认修改
    begin
      ClientDataSet1.ApplyUpdates(0);
    end;
  IDCANCEL:// 取消修改
    begin

    end;
end;

[Attach other common attributes] The
system default icon, which can be displayed on the message box

X errors MB_ICONHAND, MB_ICONSTOP, and MB_ICONERROR
? Ask MB_ICONQUESTION
! Warning MB_ICONEXCLAMATION and MB_ICONWARNING
i Information MB_ICONASTERISK and MB_ICONINFORMATION

Button form

MB_OK Default
MB_OKCANCEL Determine whether to cancel
MB_YESNO Whether
MB_YESNOCANCEL Whether to cancel

return value

IDCANCEL cancel the selected
IDNO is selected
IDOK confirm the selected
IDYES is selected


Add and submit data

Self.ClientDataSet1.Append;                // 向数据表中添加一条信息
Self.ClientDataSet1.FieldByName('id').AsString := FrmEditXinZeng.Edit1.Text;
Self.ClientDataSet1.ApplyUpdates(0);       // 提交数据表单
// 将修改的数据提交到数据库,0表示不允许发生错误

Edit and delete data

// Edit
Self.ClientDataSet1.Edit;
// Delete
Self.ClientDataSet1.Delete;


Take a few notes so you can read them later.

Guess you like

Origin blog.csdn.net/qq_44111597/article/details/108604723