database desktop에서 만든 db를 불러오는 프로그램을 간단하게 구성해봤습니다
그런데 프로그램 실행후 그림불러오는 스피드버튼을 클릭하여
그림(bitmap,ico등등)을 불러오면 불러와지지 않더군여
그리구 jpg파일은 불러오지 못하는건가여? 이리저리 인터넷에서 뒤져봐도
잘 안나와서..
한가지만더 물어볼께여..
database desktop에서 db를 만들때 그림파일을 연결시킬수 있나여?
제가 할려고 하는게 간단한 프로필을 나타내면서 폼에 테이블을 불러올때
해당하는 사람의 사진도 불러오게 하고 싶거든요..
자세히 물어보지 못해 죄송합니다 최대한 아시는대로 가르쳐 주세요..
프로그램의 소스입니다..
unit dbnavigator;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, ComCtrls, DBCtrls, StdCtrls, Mask, Buttons, ExtCtrls,
Grids, DBGrids, DB, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
SpeedButton1: TSpeedButton;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBEdit3: TDBEdit;
DBEdit4: TDBEdit;
DBImage1: TDBImage;
StatusBar1: TStatusBar;
OpenPictureDialog1: TOpenPictureDialog;
SpeedButton2: TSpeedButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
procedure DataSource1stateChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
dbnavigator1.DataSource:=datasource1;
datasource1.dataset:=table1;
dbgrid1.DataSource:=datasource1;
table1.databasename:='sungjuk1';
table1.TableName:='profile.db';
table1.Open;
//dbnavigator1.Hints.Add('처음');
dbgrid1.Columns.Items[0].Title.caption:='이름';
dbgrid1.Columns.Items[1].Title.caption:='나이';
dbgrid1.Columns.Items[2].Title.caption:='성별';
dbgrid1.Columns.Items[3].Title.caption:='신장';
//navigator1.VisibleButtons:=[nbfirst, nbprior,...];
dbgrid1.columns.Items[0].Width:=70;
dbgrid1.columns.Items[1].Width:=70;
dbgrid1.columns.Items[2].Width:=70;
dbgrid1.columns.Items[3].Width:=70;
dbgrid1.columns.Items[0].PickList.add('메디컴');
dbedit1.DataSource:=datasource1;
dbedit2.DataSource:=datasource1;
dbedit3.DataSource:=datasource1;
dbedit4.DataSource:=datasource1;
dbimage1.DataSource:=datasource1;
dbedit1.DataField:=dbgrid1.Columns.Items[0].FieldName;
dbedit2.DataField:=dbgrid1.Columns.Items[1].FieldName;
dbedit3.DataField:=dbgrid1.Columns.Items[2].FieldName;
dbedit4.DataField:=dbgrid1.Columns.Items[3].FieldName;
for i:=0 to 4 do
statusbar1.panels.add;
statusbar1.Panels[0].Width:=150;
statusbar1.Panels[1].Width:=100;
statusbar1.Panels[2].Width:=100;
statusbar1.Panels[3].Width:=100;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
if openpicturedialog1.Execute then begin
if table1.State in [dsbrowse] then table1.Edit;
dbimage1.Picture.LoadFromFile(openpicturedialog1.FileName);
table1.Post;
end;
end;
procedure TForm1.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
begin
case button of
nbfirst:statusbar1.Panels[1].Text:='''처음'' 버튼클릭';
//nbprior:..
end;
statusbar1.Panels[2].Text:='자료수:'+ inttostr(table1.recordcount)+ '개';
statusbar1.Panels[3].Text:='항목수:'+ inttostr(table1.FieldCount)+ '개';
end;
procedure TForm1.DataSource1StateChange(Sender: TObject);
begin
if (Table1.Active = false ) or (Form1.Visible = False) then Exit;//에러방지
//---------테이블의 상태를 알려준다.
Case DataSource1.State of
dsInactive:Statusbar1.Panels[0].Text:='상태: 테이블이 닫혀있습니다.';
dsBrowse:Statusbar1.Panels[0].Text:='상태: ''조회''중입니다.';
dsEdit:Statusbar1.Panels[0].Text:='상태: ''수정''상태입니다.';
dsInsert:Statusbar1.Panels[0].Text:='상태: ''입력''상태입니다.';
end;
//---테이블의 자료개수 알림
Statusbar1.Panels[2].Text:='자료수: '+Inttostr(Table1.RecordCount)+'개';
Statusbar1.Panels[3].Text:='항목수: '+Inttostr(Table1.FieldCount)+'개';
end;
end.
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
JPEG:TJPEGImage;
Bitmap:TBitmap;
begin
if openpicturedialog1.Execute then
begin
if table1.State in [dsbrowse] then table1.Edit;
// JEPG -> BMP (Convert)
JPEG := TJPEGImage.Create;
Try
Try
JPEG.LoadFromFile(openpicturedialog1.FileName);
Bitmap := TBitmap.Create;
Try
// convert JPEG to BMP
dbimage1.Picture.Bitmap.Assign(JPEG);
Finally
Bitmap.Free;
end;
Except;
dbimage1.Picture.LoadFromFile(openpicturedialog1.FileName);
End;
Finally
JPEG.Free;
end;
table1.Post;
end;
end;
조금 맘 상할라 그러네요 ㅠ.ㅠ
없는 시간 쪼개 가면서 분명히 다음카페에 답변달아드렸는데...
제가 좀 허접하긴 하지만 제 답변보다 더 좋은 답변이 나올지...