M
mingcb
Unregistered / Unconfirmed
GUEST, unregistred user!
以下程序的Button1Click在运行第二遍(即按钮的第二次点击)出错:“unsuccessful metadata update
object TMP_TJ is in use”,异常类是:“EIBInterBaseError”,原因何在?
望大侠们帮帮忙!
在Form1中有IBDatabase1.IBTransaction1.IBSQL1.IBTable1.IBDataSet1五个IB组件和一个
Button1按钮组件,InterBase数据库中有两个表:
BM_SP:BH smallint not null primary key,MC varchar(30),DY varchar(6),D1 smallint
TMP_TJ:BH smallint not null primary key,MC varchar(30),DY varchar(6)
Form1的单元程序如下:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->IBTable1->TableName="TMP_TJ";
if (Form1->IBTable1->Exists) {
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("drop table TMP_TJ");
Caption="1111111111111";
Form1->IBSQL1->ExecQuery();
Caption="2222222222222";
Form1->IBTransaction1->CommitRetaining();
}
//----------------------------------
Caption="333333333";
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("create table TMP_TJ (BH smallint /
not null primary key,MC varchar(30),DY varchar(6),/
D1 smallint)");
Form1->IBSQL1->ExecQuery();
Form1->IBTransaction1->CommitRetaining();
Caption="444444444444";
//------------------------------
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("insert into TMP_TJ (BH,MC,DY) /
select BH,MC,DY from BM_SP");
Form1->IBSQL1->ExecQuery();
Caption="555555555555";
//Form1->IBTransaction1->CommitRetaining();
Caption="666666666666";
//----------------------------------
Form1->IBDataSet1->Active=false;
Form1->IBDataSet1->SelectSQL->Clear();
Form1->IBDataSet1->RefreshSQL->Clear();
Form1->IBDataSet1->InsertSQL->Clear();
Form1->IBDataSet1->ModifySQL->Clear();
Form1->IBDataSet1->DeleteSQL->Clear();
Form1->IBDataSet1->SelectSQL->Add("select * from TMP_TJ");
Form1->IBDataSet1->RefreshSQL->Add("select * from TMP_TJ /
where BH=:BH");
Form1->IBDataSet1->InsertSQL->Add("insert into TMP_TJ /
(BH,MC,DY,D1) valuesBH,:MC,Y,1)");
Form1->IBDataSet1->ModifySQL->Add("update TMP_TJ set /
BH=:BH,MC=:MC,DY=Y,D1=1 where BH=:OLD_BH");
Form1->IBDataSet1->DeleteSQL->Add("delete from TMP_TJ /
where BH=:OLD_BH");
Form1->IBDataSet1->Active=true;
Caption="7777777777";
Form1->IBDataSet1->Active=false;
Form1->IBTransaction1->CommitRetaining();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
this->IBDatabase1->Connected=true;
this->IBTransaction1->Active=true;
}
object TMP_TJ is in use”,异常类是:“EIBInterBaseError”,原因何在?
望大侠们帮帮忙!
在Form1中有IBDatabase1.IBTransaction1.IBSQL1.IBTable1.IBDataSet1五个IB组件和一个
Button1按钮组件,InterBase数据库中有两个表:
BM_SP:BH smallint not null primary key,MC varchar(30),DY varchar(6),D1 smallint
TMP_TJ:BH smallint not null primary key,MC varchar(30),DY varchar(6)
Form1的单元程序如下:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->IBTable1->TableName="TMP_TJ";
if (Form1->IBTable1->Exists) {
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("drop table TMP_TJ");
Caption="1111111111111";
Form1->IBSQL1->ExecQuery();
Caption="2222222222222";
Form1->IBTransaction1->CommitRetaining();
}
//----------------------------------
Caption="333333333";
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("create table TMP_TJ (BH smallint /
not null primary key,MC varchar(30),DY varchar(6),/
D1 smallint)");
Form1->IBSQL1->ExecQuery();
Form1->IBTransaction1->CommitRetaining();
Caption="444444444444";
//------------------------------
Form1->IBSQL1->SQL->Clear();
Form1->IBSQL1->SQL->Add("insert into TMP_TJ (BH,MC,DY) /
select BH,MC,DY from BM_SP");
Form1->IBSQL1->ExecQuery();
Caption="555555555555";
//Form1->IBTransaction1->CommitRetaining();
Caption="666666666666";
//----------------------------------
Form1->IBDataSet1->Active=false;
Form1->IBDataSet1->SelectSQL->Clear();
Form1->IBDataSet1->RefreshSQL->Clear();
Form1->IBDataSet1->InsertSQL->Clear();
Form1->IBDataSet1->ModifySQL->Clear();
Form1->IBDataSet1->DeleteSQL->Clear();
Form1->IBDataSet1->SelectSQL->Add("select * from TMP_TJ");
Form1->IBDataSet1->RefreshSQL->Add("select * from TMP_TJ /
where BH=:BH");
Form1->IBDataSet1->InsertSQL->Add("insert into TMP_TJ /
(BH,MC,DY,D1) valuesBH,:MC,Y,1)");
Form1->IBDataSet1->ModifySQL->Add("update TMP_TJ set /
BH=:BH,MC=:MC,DY=Y,D1=1 where BH=:OLD_BH");
Form1->IBDataSet1->DeleteSQL->Add("delete from TMP_TJ /
where BH=:OLD_BH");
Form1->IBDataSet1->Active=true;
Caption="7777777777";
Form1->IBDataSet1->Active=false;
Form1->IBTransaction1->CommitRetaining();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
this->IBDatabase1->Connected=true;
this->IBTransaction1->Active=true;
}