在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库
来源:互联网 发布:mac 安装 webpack 编辑:程序博客网 时间:2024/06/09 23:44
在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库
王大川(WDCZZH)
最近在CSDN上看到两篇关于《DELPHI中存取JPEG文件到SQLSERVER》中的文章之后,觉得其中讲述的方法虽然有可取之处,但颇费时,我这里有更简单的操作方法,而且安全可靠,不敢一人独享,愿发布出来与大家共享。在DELPHI7.0+Win2000+SQLSERVER 2000中测试通过,运行良好,现将思路、源码公开如下:
解决思路:
1、 关键在于将打开的JPEG文件动态转换为Tbitmap对象并显示在Timage对象中;
2、 将显示的图片提交到数据库中。
本例中在SQLSERVER2000中建立了一个试例表:exam(xm char(10),photo image);
程序源代码:
unit SavePic;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, ExtCtrls, DBCtrls, Grids, DBGrids, DB, ADODB, Buttons,
StdCtrls,JPEG;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
ADOConnection1: TADOConnection;
Table1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBImage1: TDBImage;
Image1: TImage;
SpeedButton2: TSpeedButton;
OpenPictureDialog1: TOpenPictureDialog;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
SpeedButton3: TSpeedButton;
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
bmp1:TBitmap;
jpg1:TJPEGImage;
begin
OpenPictureDialog1.DefaultExt:=GraphicExtension(TJPEGimage);
if OpenPictureDialog1.Execute then
begin
bmp1:=TBitmap.Create;
jpg1:=TJPEGImage.Create;
try
jpg1.LoadFromFile(OpenPictureDialog1.FileName);
bmp1.Assign(jpg1);
Image1.Picture.Bitmap.Assign(bmp1);
finally
jpg1.Free;
bmp1.Free;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
table1.Open;
table1.insert;
table1.fieldbyname('xm').asstring:=Edit1.Text;
table1.FieldByName('photo').Assign(Image1.Picture);
table1.post;
table1.Refresh;
end;
end.
以上就是将JPEG存取到SQLSERVER中的操作方法,本文在此仅是抛砖引玉,希望各位朋友举一反三想出更多、更好、更实用的应用技术,公布到CSDN为大家造福。
欢迎各位朋友来Email交流:wdcwy@tom.com
QQ:11711941
- 在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库-Delphi-编程开发
- 在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库-Delphi-编程开发
- 在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库
- 在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库
- DELPHI存取JPEG文件到SQL Server数据库
- DELPHI存取JPEG文件到SQL Server数据库(续文)
- DELPHI存取JPEG文件到SQL Server数据库 [转]
- DELPHI存取JPEG文件到SQL Server数据库(续文)
- DELPHI存取JPEG文件到SQL Server数据库
- DELPHI存取JPEG文件到SQL Server数据库
- DELPHI存取JPEG文件到SQL Server数据库
- DELPHI存取JPEG、BMP图像到数据库完整解决方案
- [转]Delphi存取JPEG、BMP图像到数据库完整解决方案
- Delphi存取JPEG、BMP图像到数据库完整解决方案
- DELPHI存取JPEG、BMP图像到数据库完整解决方案
- 在DELPHI中SQL存取JPEG方法 (转)
- C# 在SQLSERVER数据库中存取图片
- C# 在SQLSERVER数据库中存取图片
- 教你如何使用触发器管理MySQL数据库
- 用Delphi创建COM+ 应用服务器(二)
- 在MySQL中获得更好的全文搜索结果
- 利用Delphi编写Socket通信程序
- 教你编写高质量、高性能的MySQL语法
- 在DELPHI中更简单的存取JPEG文件到SQLSERVER数据库
- 用CSS样式实现显示隐藏层
- 关于MySQL数据库的存储引擎详细介绍
- New Page 1
- 妙用CSS滤镜为图片加上特殊效果
- MySQL和PostgreSQLl两数据库的对决
- NeHe的opengl教程delphi版(1)----基本框架
- NeHe的opengl教程delphi版(2)----创建三角形和四边形
- MySQL 5 C API 访问数据库例子程序