数据库存储图片问题 如果把图片直接存储到数据库上,数据就很大.运行慢,不宜备分,但是保存图片路径,在C/S中就得访问数据库服务器,难道每次都要输入用户名密码什么的吗?即使把用户名和密码作成参数也不太方便吧,又更好得方法吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据库连接控件都有loginPrompt属性,设置成False,就不用每次都填用户和密码了 use jpeg就可以使用JPG图片了。 其实有一个很简单的方法存取图象(仅限BMP和JPEG)到数据库字段中,不需要使用流,我初学还不会流。 这是我的一个代码:unit Unitpic;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DBCtrls, StdCtrls, DB, Grids, DBGrids, ADODB, Mask;type TForm1 = class(TForm) ADOTable1: TADOTable; DataSource1: TDataSource; DBGrid1: TDBGrid; ADOTable1DSDesigner: TWideStringField; ADOTable1DSDesigner2: TWideStringField; ADOTable1DSDesigner3: TBlobField; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; DBImage1: TDBImage; OpenDialog1: TOpenDialog; DBEdit1: TDBEdit; DBComboBox1: TDBComboBox; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure DBImage1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin if not adotable1.Bof then adotable1.Prior;end;procedure TForm1.Button2Click(Sender: TObject);begin if not adotable1.Eof then adotable1.Next;end;procedure TForm1.Button3Click(Sender: TObject);begin adotable1.Insert;end;procedure TForm1.Button4Click(Sender: TObject);begin adotable1.Delete; if adotable1.Eof then showmessage('没有数据了!');end;procedure TForm1.DBImage1Click(Sender: TObject);begin if opendialog1.Execute then begin adotable1.Edit; ADOTable1DSDesigner3.LoadFromFile(opendialog1.FileName); end;end;end. 参数传递问题请教 请教大家一个delphi中的小问题? project 菜单? 辞职后的第一件事:发布中国软件专家门诊离线数据浏览器(简记:Csdn Explorer),望各位朋友支持! 界面的问题 关于ComboBox的问题,请高手赐教!!! 线程注入技术 IE高手请进,关于程序中IE控件中的网页保存。 SQL 问题 李维的网站where? 多谢XDJM 高分请教高手: 在TDBGrid 这个第三方控件中,如何实现+ - 层叠功能?
就可以使用JPG图片了。
其实有一个很简单的方法存取图象(仅限BMP和JPEG)到数据库字段中,不需要使用流,我初学还不会流。
这是我的一个代码:unit Unitpic;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBCtrls, StdCtrls, DB, Grids, DBGrids, ADODB, Mask;type
TForm1 = class(TForm)
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
ADOTable1DSDesigner: TWideStringField;
ADOTable1DSDesigner2: TWideStringField;
ADOTable1DSDesigner3: TBlobField;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
DBImage1: TDBImage;
OpenDialog1: TOpenDialog;
DBEdit1: TDBEdit;
DBComboBox1: TDBComboBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure DBImage1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if not adotable1.Bof then
adotable1.Prior;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
if not adotable1.Eof then
adotable1.Next;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
adotable1.Insert;
end;procedure TForm1.Button4Click(Sender: TObject);
begin
adotable1.Delete;
if adotable1.Eof then
showmessage('没有数据了!');
end;procedure TForm1.DBImage1Click(Sender: TObject);
begin
if opendialog1.Execute then
begin
adotable1.Edit;
ADOTable1DSDesigner3.LoadFromFile(opendialog1.FileName);
end;
end;end.