제가 지금 MysqlDB를 이용한 프로그램은 만들고 있는데...
컴포넌트로 zeos를 사용하고 있습니다..
근데 Query쪽에서 에러가 납니다...
알고 계신분 꼭 좀 갈켜 주세요!!! 꼭~
소스랑 에러메세지 올립니다.
============== Error 메세지 =========================================
Project1.exe raised exception class EDatabaseError with message 'Transaction component not defined'.
Process stopped. Use Step or Run to continue.
====================================================================
================= 소스 ==============================================
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, StdCtrls, Grids,
Buttons, Db, DBTables, ZConnect, ZMySqlCon, ZQuery, ZMySqlQuery ;
type
TFrm_user = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Label1: TLabel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
Panel7: TPanel;
Panel8: TPanel;
BitBtn_reset: TBitBtn;
Btn_In: TBitBtn;
Btn_modi: TBitBtn;
Btn_Exit: TBitBtn;
Btn_del: TBitBtn;
Label2: TLabel;
SGrid_user: TStringGrid;
name_Edit: TEdit;
id_Edit: TEdit;
pw_Edit: TEdit;
Panel9: TPanel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
ZMySqlDB: TZMySqlDatabase;
MySqlQuery_user1: TZMySqlQuery;
MySqlQueryTemp: TZMySqlQuery;
procedure BitBtn_resetClick(Sender: TObject);
procedure Btn_ExitClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Btn_InClick(Sender: TObject);
procedure Btn_delClick(Sender: TObject);
procedure name_EditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure id_EditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure pw_EditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SGrid_userDblClick(Sender: TObject);
procedure SGrid_userMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_user: TFrm_user;
implementation
{$R *.DFM}
procedure TFrm_user.BitBtn_resetClick(Sender: TObject);
begin
if MESSAGEDLG('모든 정보를 초기화 하시겠습니까?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
name_Edit.Clear;
id_Edit.Clear;
pw_Edit.Clear;
end
else begin Exit; end;
end;
procedure TFrm_user.Btn_ExitClick(Sender: TObject);
begin
if MessageDlg(' 종료 하시겠습니까? ',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
Close;
end
else begin exit; end
end;
procedure TFrm_user.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Release;
end;
procedure TFrm_user.FormCreate(Sender: TObject);
var
i: integer;
begin
Label3.Caption := ' '+formatdatetime('yyyy-mm-dd (ddd)',now);
Edit1.Clear;
name_Edit.Clear;
id_Edit.Clear;
pw_Edit.Clear;
with SGrid_user do
begin
RowHeights[0] := 21;
Cells[ 0,0] := ' 번 호'; ColWidths[ 0] :=80;
Cells[ 1,0] := ' 성 명'; ColWidths[ 1] :=100;
Cells[ 2,0] := ' I D'; ColWidths[ 2] :=100;
Cells[ 3,0] := ' PassWord'; ColWidths[ 3] :=100;
end;
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from ymember ');
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
SGrid_user.RowCount := MySqlQuery_user1.RecordCount +1;
for i := 1 to SGrid_user.RowCount - 1 do
begin
SGrid_user.Cells[0,i]:=MySqlQuery_user1.FieldByName('idx').asstring;
SGrid_user.Cells[1,i]:=MySqlQuery_user1.FieldByName('yname').asstring;
SGrid_user.Cells[2,i]:=MySqlQuery_user1.FieldByName('yid').asstring;
SGrid_user.Cells[3,i]:=MySqlQuery_user1.FieldByName('ypass').asstring;
SGrid_user.RowHeights[i] := 21;
MySqlQuery_user1.next;
end;
end;
procedure TFrm_user.Btn_InClick(Sender: TObject);
var
i : Integer;
Data : array [1..4] of string;
begin
Data[1]:= Edit1.Text;
Data[2]:= name_Edit.Text;
Data[3]:= id_Edit.Text;
Data[4]:= pw_Edit.Text;
if Data[2]='' then
begin
Showmessage('이름를 입력하세요!!');
name_Edit.SetFocus;
Exit;
end
else if data[3] ='' then begin
showmessage('아이디를 입력하세요!!');
id_Edit.SetFocus ;
Exit;
end
else if data[4] = '' then begin
showmessage('비밀번호를 입력하세요!!');
pw_Edit.SetFocus ;
Exit;
end
else begin
Next;
end;
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from ymember ');
MySqlQuery_user1.SQL.Add(' where yid = '+ Quotedstr(trim(Data[2])));
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
// Try
// ZMySqlDB.StartTransaction;
if not MySqlQuery_user1.Eof then
begin
// 에디터 박스에 입력한 데이타를 수정 할것인지 사용자의 확인을 위해 질문한다.
if MESSAGEDLG('아이디 '+ Trim(Data[2]) +' 가 중복 됩니다, 수정하시겠습니까?',
mtconfirmation,[mbyes,mbno],0)=mryes then
begin
// 입력을 받은 데이타와 변수들과의 조화에 의해 DB에 업데이트한다.
MySqlQueryTemp.close;
MySqlQueryTemp.SQL.Clear;
MySqlQueryTemp.SQL.Add(' Update YMEMBER set ' +
' yname ='+ Quotedstr(Trim(data[2])) +','+
//' yid ='+ Quotedstr(Trim(data[3]))+','+
' ypass ='+ Quotedstr(Trim(data[4])) +
' Where yid = '+ Quotedstr(Trim(data[2])));
MySqlQueryTemp.ExecSQL;
end //if MESSAGEDLG('사원코드 ' ~ ) then
else begin
name_Edit.SetFocus; // 취소버튼을 누르면 포커스가 사원코드 에디터박스로 이동한다.
end;
end //if not Queryuser1.Eof then
else if MySqlQuery_user1.Eof then
begin
if // 에디터 박스에 입력한 데이타(사원코드)를 저장 할것인지 사용자의 확인을 위해 질문한다.
MESSAGEDLG('성명: '+ Trim(Data[2]) + ' 아이디: '+Trim(Data[3])+' 을 저장하시겠습니까?',
mtconfirmation,[mbyes,mbno],0)=mryes then
begin
// 입력을 받은 데이타와 변수들과의 조화에 의해 DB에 저장한다.
MySqlQueryTemp.Close;
MySqlQueryTemp.SQL.Clear;
MySqlQueryTemp.SQL.Add('insert into YMEMBER(yname,yid,ypass)values('+
Quotedstr(Trim(Data[2]))+','+
Quotedstr(Trim(Data[3]))+','+
Quotedstr(Trim(Data[4]))+')');
MySqlQueryTemp.ExecSQL;
end //if MESSAGEDLG('사원코드: '+ Trim(Data[1]) ~ ) then
else begin
name_Edit.SetFocus; // 취소버튼을 누르면 포커스가 사원코드 에디터박스로 이동한다.
end;
end; //else if QuerySawon.Eof then
// ZMySqlDB.Commit;
Edit1.Clear;
name_Edit.Clear;
id_Edit.Clear;
pw_Edit.Clear;
name_Edit.SetFocus;
// Except begin
// ZMySqlDB.Rollback;
// end; //Except ~
// end; // Try ~
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from YMEMBER ');
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
SGrid_user.RowCount := MySqlQuery_user1.RecordCount +1;
for i := 1 to SGrid_user.RowCount - 1 do
begin
SGrid_user.Cells[0,i]:=MySqlQuery_user1.FieldByName('idx').asstring;
SGrid_user.Cells[1,i]:=MySqlQuery_user1.FieldByName('yname').asstring;
SGrid_user.Cells[2,i]:=MySqlQuery_user1.FieldByName('yid').asstring;
SGrid_user.Cells[3,i]:=MySqlQuery_user1.FieldByName('ypass').asstring;
SGrid_user.RowHeights[i] := 21;
MySqlQuery_user1.next;
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from ymember ');
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
SGrid_user.RowCount := MySqlQuery_user1.RecordCount +1;
for i := 1 to SGrid_user.RowCount - 1 do
begin
SGrid_user.Cells[0,i]:=MySqlQuery_user1.FieldByName('idx').asstring;
SGrid_user.Cells[1,i]:=MySqlQuery_user1.FieldByName('yname').asstring;
SGrid_user.Cells[2,i]:=MySqlQuery_user1.FieldByName('yid').asstring;
SGrid_user.Cells[3,i]:=MySqlQuery_user1.FieldByName('ypass').asstring;
SGrid_user.RowHeights[i] := 21;
MySqlQuery_user1.next;
end;
end;
procedure TFrm_user.Btn_delClick(Sender: TObject);
var
i : Integer;
Data : array [1..4] of string;
begin
Data[1]:= Edit1.Text;
Data[2]:= name_Edit.Text;
Data[3]:= id_Edit.Text;
Data[4]:= pw_Edit.Text;
if MessageDlg(Trim(Data[2])+' , '+ Trim(Data[3]) +' 님의 정보를 삭제 하시겠습니까?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from ymember ');
MySqlQuery_user1.SQL.Add(' where yid = '+ Quotedstr(trim(Data[3])));
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
// try
// ZMySqlDB.StartTransaction ;
if not MySqlQuery_user1.EOF then begin
MySqlQueryTemp.close ;
MySqlQueryTemp.sql.Clear ;
MySqlQueryTemp.sql.Add('Delete from ymember '+
' where yid =' + Quotedstr(data[3]));
//Querytemp.SQL.SaveToFile('c:Bde.txt');
MySqlQueryTemp.ExecSQL ;
end
else if MySqlQuery_user1.EOF then begin
end;
// ZMySqlDB.Commit;
// Except
// ZMySqlDB.Rollback;
// end; //Except
// MessageDlg('삭제 하였습니다', mtInformation,[mbOk], 0);
//lose;
// end;
MySqlQuery_user1.Close;
MySqlQuery_user1.SQL.Clear;
MySqlQuery_user1.SQL.Add(' select idx,yname,yid,ypass ');
MySqlQuery_user1.SQL.Add(' from ymember ');
MySqlQuery_user1.SQL.Add(' order by idx ');
MySqlQuery_user1.Open;
SGrid_user.RowCount := MySqlQuery_user1.RecordCount +1;
for i := 1 to SGrid_user.RowCount - 1 do
begin
SGrid_user.Cells[0,i]:=MySqlQuery_user1.FieldByName('idx').asstring;
SGrid_user.Cells[1,i]:=MySqlQuery_user1.FieldByName('yname').asstring;
SGrid_user.Cells[2,i]:=MySqlQuery_user1.FieldByName('yid').asstring;
SGrid_user.Cells[3,i]:=MySqlQuery_user1.FieldByName('ypass').asstring;
SGrid_user.RowHeights[i] := 21;
MySqlQuery_user1.next;
end;
Edit1.Clear;
name_Edit.Clear;
id_Edit.Clear;
pw_Edit.Clear;
end;
======================================================================
소스가 넘 긴가??? ^^;
그럼 고수님들 꼭 좀 갈켜 주세요!!!
저도 비슷한 에러메시지였었는데 참고하세요..
메뉴중에 Project==>Option 가시면 패키지 부분에
Build With RunTime Packages 가 체크되어있는지 확인해보시구 컴파일 해보세요.