——此文章摘自《Delphi开发经验技巧宝典》定价
¥
特价
¥
购买>>http://track
linktech
cn/?m_id=dangdang&a_id=A
&l=
&l_type
=
width=
height=
border=
nosave>
本例通过SQL语句把员工的信息存入到数据库中主要代码如下
procedure TFrmTransBtnSaveClick(Sender: TObject);
var
ADOQuery: TADOQuery;
SQL: string;
begin
ADOQuery := TADOQueryCreate(nil);
ADOQueryConnection := ADOConn;
SQL :=
Insert Into TB_Worker(NumberNameOldSexTelePhoneDepartMentJoinDate) ;
SQL := SQL +
Values(:Number:Name:Old:Sex:TelePhone:DepartMent:JoinDate);
ADOQuerySQLAdd(SQL);
with ADOQueryParameters do
begin
ParamByName(Number)Value := Trim(EDNumberText);
ParamByName(Name)Value := Trim(EDNameText);
ParamByName(Old)Value := StrToIntDef(Trim(EdOldText) );
if CBxSexText = 男 then
ParamByName(Sex)Value :=
else
ParamByName(Sex)Value := ;
ParamByName(TelePhone)Value := Trim(EdTelePhoneText);
ParamByName(DepartMent)Value := Trim(CBXdePartMentText);
ParamByName(JoinDate)Value := DTPJoinDateDate;
end;
try
ADOQueryExecSQL;
finally
ADOQueryFree;
end;
ADODataSetRequery();
GBxListEnabled := False;
BtnSaveEnabled := False;
BtnNewEnabled := True;
ShowMessage(数据保存成功);
end;