服务器端过程。
procedure TSrv_Teacher.Srv_OpenTeacherTableR0ByID(const RequireID: WideString;
TID: Integer);
var
sql:String;
begin
if RequireID='True' then
begin
sql:='SELECT * FROM teacher_info WHERE Retire_Flag='+#39+'0'+#39+' AND ID='+IntToStr(TID);
end;
if RequireID='False' then
begin
sql:='SELECT ID,Number,Sex,RealName,UserName,UserPass,Email,BirthDay,PersonNum,ToSchoolDay,';
sql:=sql+'WorkClass,WorkGroup,RetainInfo,JobName,Contact,Address,LastLearn,Graduate,Pic,Memo,Retire_Flag ';
sql:=sql+'FROM teacher_info';// WHERE ID='+inttostr(1);
end;
self.ADOQuery_Info.Close;
self.ADOQuery_Info.Connection:=self.ADOConnection_M;
self.ADOQuery_Info.SQL.Clear;
self.ADOQuery_Info.SQL.Add(sql);
self.ADOQuery_Inf
pen;
end;
客户端:图片是可以载入的,如果是jpg的存入数据库就太大,有没有更好的办法来存图片
function TInfoManForm.ZCP_LoadPictureTo_Box():boolean;
var
OPenPictureDialog_tmp:TOpenPictureDialog;
jpg:TJpegImage;
bmp:TBitmap;
begin
//如果数据体没有打开,则跳出
if self.ClientDataSet_Info.Active=false then
begin
Result:=false;
exit;
end;
//Windows.GetCursorPos(Point_P);
//self.PopupMenu_Pic.Popup(Point_P.X,Point_P.Y);
OPenPictureDialog_tmp:=TOpenPictureDialog.Create(self);
OPenPictureDialog_tmp.Filter:='*.bmp|*.bmp;*.jpg|*.jpg|*.jpg|所有文件(*.*)|*.*';
if OPenPictureDialog_tmp.Execute then
begin
if OpenPictureDialog_tmp.FileName<>'' then
begin
self.ClientDataSet_Info.Edit;
self.E_DBImage_Pic.Picture.LoadFromFile(OPenPictureDialog_tmp.FileName);
//将jpg转化为bmp
if self.E_DBImage_Pic.Picture.Graphic is TjpegImage then
begin
jpg:=TJpegImage.Create;
bmp:=TBitmap.Create;
jpg.Assign(self.E_DBImage_Pic.Picture);
//jpg.Compress;
bmp.Assign(jpg);
//self.St_Image.Picture.Assign(bmp);
self.ClientDataSet_Info.FieldByName('Pic').Assign(bmp);
jpg.Free;
bmp.Free;
end;
//self.ClientDataSet_Info.Post;
end;
end;
OPenPictureDialog_tmp.Free;
Result:=true;
end;