| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Nuevo Invitado
|
Publicado: Sab 07 May, 2005 3:47 pm Asunto: error "Table 1 Cannot perform this operation on closed |
|
|
En una aplicación abro do tablas diferente pero cuando abro la primera sin problema la cierro abro la segunda y la cierro pero cuando tengo q abrir otra vez la primera me un error "Table 1 Cannot perform this operation on closed Dataset"
Solución que puede ser o q estoy haciendo mal
Gracias a todos |
|
| Volver arriba |
|
 |
Tugui Master


Registrado: 09 Nov 2002Mensajes: 663
|
Publicado: Sab 07 May, 2005 9:27 pm Asunto: |
|
|
Sería de gran ayuda si nos pusieras el código que utilizas. Sin ver el código es un tanto complicado decirte con exactitud cual es el error. _________________ ¡ADELANTE CON ESTE SUPER FORO! |
|
| Volver arriba |
|
 |
Invitado Invitado
|
Publicado: Lun 09 May, 2005 6:17 pm Asunto: HOla Tugui |
|
|
Hola Tugui
Es e codigo es el siguiente
3 Forma
Form1
aplicacion que llama form 2 o form3
Form2
//---------------------------------------------------------------------------
void __fastcall TForm6::FormDestroy(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormClose(TObject *Sender, TCloseAction &Action)
{
Form1->Visible = true;
Form1->Enabled = true;
Form6->Visible = false;
Form6->Enabled = false;
Table1->Active = false;
Table2->Active = false;
Table3->Active = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormCreate(TObject *Sender)
{
DateTimePicker1->Date = Date();
DateTimePicker2->Date = Date();
DateTimePicker3->Date = Date();
Table1->Active = true;
Table2->Active = true;
Table1->Refresh();
Table2->Refresh();
Table1->First();
while (!Table1->Eof)
{
ComboBox1->Items->Add(Table1->FieldByName("Area")->AsString);
Table1->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm6::ComboBox1Change(TObject *Sender)
{
ComboBox2->Clear();
int x;
x = StrToInt(Table1->RecordCount);
AnsiString Cod, Cod2;
Table1->First();
for (int i = 0; i <= x; i++)
{
if(ComboBox1->Text == Table1->FieldByName("Area")->AsString)
{
Cod = Table1->FieldByName("Iniciales")->AsString + Table1->FieldByName("Centro")->AsString;
Table2->Filtered = true;
Table2->Filter = " Codarea = '" + Cod + "'";
Table2->First();
while (!Table2->Eof)
{
ComboBox2->Items->Add(Table2->FieldByName("Maquina")->AsString);
Table2->Next();
}
break ;
}
else
Table1->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm6::ComboBox2Change(TObject *Sender)
{
int x;
x = StrToInt(Table2->RecordCount);
Table2->First();
for (int i = 0; i <= x; i++)
{
if(ComboBox2->Text == Table2->FieldByName("Maquina")->AsString)
{
MasterCod = Table2->FieldByName("Codmaquina")->AsString;
}
else
Table2->Next();
}
//-----------------------------------------
Edit4->Text = ComboBox2->Text;
Edit5->Text = MasterCod;
//-----------------------------------------
//Abriendo Base de datos selecionada
Table3->Active = false;
Table3->DatabaseName = ExtractFilePath(Application->ExeName);
Table3->TableName = MasterCod + ".db";
Table3->Active = true;
ShowMessage("Hola");
//-----------------------------------------
Label1->Caption = "";
Label2->Caption = "";
//ComboBox1->Visible = false;
//ComboBox2->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::BitBtn1Click(TObject *Sender)
{
//-----------------------------------------
// Manejo de la tabla
Table3->Insert();
Table3->Append();
Table3->FieldValues["OTP"] = true;
Table3->FieldValues["Fecha"] = DateTimePicker3->Date;
Table3->FieldValues["Solicitante"] = Edit->Text;
Table3->FieldValues["Departamento"] = Edit2->Text;
Table3->FieldValues["Turno"] = Edit3->Text;
Table3->FieldValues["Maquina"] = Edit4->Text;
Table3->FieldValues["Codigo"] = Edit5->Text;
Table3->FieldValues["Tipotrabajo"] = ComboBox3->Text;
Table3->FieldValues["Tipomtto"] = ComboBox4->Text;
Table3->FieldValues["Finicio"] = DateTimePicker1->Date;
Table3->FieldValues["Hinicio"] = MaskEdit3->Text;
Table3->FieldValues["Ffinal"] = DateTimePicker2->Date;
Table3->FieldValues["Hfinal"] = MaskEdit5->Text;
Table3->FieldValues["Actividades"] = Memo1->Text;
Table3->FieldValues["Observaciones"] = Memo2->Text;
Table3->Post();
//-----------------------------------------
Label1->Caption = "Area:";
Label2->Caption = "Maquina:";
ComboBox1->Visible = true;
ComboBox2->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormCloseQuery(TObject *Sender, bool &CanClose)
{
Table1->Active = false;
Table2->Active = false;
Table3->Active = false;
}
//---------------------------------------------------------------------------
Form2
//---------------------------------------------------------------------------
void __fastcall TForm8::FormClose(TObject *Sender, TCloseAction &Action)
{
DBGrid1->Visible = false;
DBMemo1->Visible = false;
DBMemo2->Visible = false;
DBNavigator1->Visible = false;
Form1->Visible = true;
Form1->Enabled = true;
Form8->Visible = false;
Form8->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm8::FormDestroy(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm8::ComboBox1Change(TObject *Sender)
{
ComboBox2->Clear();
int x;
x = StrToInt(Table1->RecordCount);
AnsiString Cod, Cod2;
Table1->First();
for (int i = 0; i <= x; i++)
{
if(ComboBox1->Text == Table1->FieldByName("Area")->AsString)
{
Cod = Table1->FieldByName("Iniciales")->AsString + Table1->FieldByName("Centro")->AsString;
Table2->Filtered = true;
Table2->Filter = " Codarea = '" + Cod + "'";
Table2->First();
while (!Table2->Eof)
{
ComboBox2->Items->Add(Table2->FieldByName("Maquina")->AsString);
Table2->Next();
}
break ;
}
else
Table1->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm8::ComboBox2Change(TObject *Sender)
{
int x;
x = StrToInt(Table2->RecordCount);
Table2->First();
for (int i = 0; i <= x; i++)
{
if(ComboBox2->Text == Table2->FieldByName("Maquina")->AsString)
{
MasterCod1 = Table2->FieldByName("Codmaquina")->AsString;
}
else
Table2->Next();
}
Table3->Active = false;
Table3->DatabaseName = ExtractFilePath(Application->ExeName);
Table3->TableName = MasterCod1 + ".db";
Table3->Active = true;
DBGrid1->Visible = true;
DBMemo1->Visible = true;
DBMemo2->Visible = true;
DBNavigator1->Visible = true;
BitBtn1->Enabled = true;
BitBtn1->Visible = true;
BitBtn2->Enabled = true;
BitBtn2->Visible = true;
BitBtn3->Enabled = true;
BitBtn3->Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm8::BitBtn1Click(TObject *Sender)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm8::FormCloseQuery(TObject *Sender, bool &CanClose)
{
Table1->Active = false;
Table2->Active = false;
Table3->Active = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm8::FormShow(TObject *Sender)
{
Table1->Active = true;
Table2->Active = true;
Table1->Refresh();
Table2->Refresh();
Table1->First();
while (!Table1->Eof)
{
ComboBox1->Items->Add(Table1->FieldByName("Area")->AsString);
Table1->Next();
}
}
//--------------------------------------------------------------------------- |
|
| Volver arriba |
|
 |
Buildero Master


Registrado: 23 Dic 2003Mensajes: 523Ubicación: Puebla, México
|
Publicado: Lun 09 May, 2005 6:39 pm Asunto: |
|
|
No le he probado, pero posiblemente el error se está presentando en el evento OnChange del o de los combos.
Sugiero que verifiques que si la tabla esta abierta ejecutar el código correspondiente.
| Código: |
i
void __fastcall TForm6::ComboBox1Change(TObject *Sender)
{
if ( Table1->Active ) // Nueva linea
{
ComboBox2->Clear();
int x;
x = StrToInt(Table1->RecordCount);
AnsiString Cod, Cod2;
Table1->First();
for (int i = 0; i <= x; i++)
{
if(ComboBox1->Text == Table1->FieldByName("Area")->AsString)
{
Cod = Table1->FieldByName("Iniciales")->AsString + Table1->FieldByName("Centro")->AsString;
Table2->Filtered = true;
Table2->Filter = " Codarea = '" + Cod + "'";
Table2->First();
while (!Table2->Eof)
{
ComboBox2->Items->Add(Table2->FieldByName("Maquina")->AsString);
Table2->Next();
}
break ;
}
else
Table1->Next();
}
}
}
|
_________________ Quien hace una pregunta teme parecer un ignorante durante cinco minutos, quien no pregunta se mantiene ignorante toda la vida. |
|
| Volver arriba |
|
 |
|