BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error SQL embeded

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Guillermo Díaz
Guest





PostPosted: Sun Apr 18, 2004 6:20 pm    Post subject: Error SQL embeded Reply with quote




Hi!

In an application, the first time that I record a registration master/detail makes it correctly. But later on, without leaving and without closing the involved files, I am obtaining the following message "Couldn't perform the edit because another user changed the record" when I use Interbase 5.6. But when I use Paradox 7 it seems to work well.

The code is the following one:

void __fastcall TFrmTerceros::GrabarClick(TObject *Sender)
{
int i;

DtMdl->DtbsPpal->StartTransaction();
QryBorrar->ParamByName("Cod")->AsInteger=CodIntTer->Caption.ToInt(); //For to delete the registers details.

try{

if(Ter->FindKey(ARRAYOFCONST((ClaIdentif->Text,Identif->Text))) && Ter->FieldByName("CodIntTer")->AsString==CodIntTer->Caption)
Ter->Edit();
else{
Ter->Append();
Ter->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
}

Ter->FieldByName("ClaIdentif")->AsString=ClaIdentif->Text;
Ter->FieldByName("Identif")->AsString=Identif->Text;
Ter->FieldByName("DigCtrl")->AsString=DigCtrl->Text;
Ter->FieldByName("Nombre")->AsString=Nombre->Text;
Ter->Post();

Dir->Close();
QryBorrar->ExecSQL(); //Delete all records “details”
Dir->Open();

//Eliminación de sucursales sobrantes del Tercero
for(i=1;(i<Grilla->RowCount && !EsVacio(Grilla->Cells[CODSUC][i].c_str()));i++){
Dir->Append();
Dir->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
Dir->FieldByName("CodSuc")->AsString=Grilla->Cells[CODSUC][i];
Dir->FieldByName("NomSuc")->AsString=Grilla->Cells[NOMBRE][i];
Dir->FieldByName("Dir")->AsString=Grilla->Cells[DIR][i];
Dir->FieldByName("Tel1")->AsString=Grilla->Cells[TEL1][i];
Dir->FieldByName("Tel2")->AsString=Grilla->Cells[TEL2][i];
Dir->FieldByName("Fax")->AsString=Grilla->Cells[FAX][i];
Dir->FieldByName("EMail")->AsString=Grilla->Cells[EMAIL][i];
Dir->FieldByName("ApdoAereo")->AsString=Grilla->Cells[APDOAEREO][i];
Dir->FieldByName("Ciudad")->AsString=Grilla->Cells[CIU][i];
Dir->FieldByName("Provincia")->AsString=Grilla->Cells[PROV][i];
Dir->FieldByName("Autonomia")->AsString=Grilla->Cells[AUTONOM][i];
Dir->FieldByName("Pais")->AsString=Grilla->Cells[PAIS][i];
Dir->FieldByName("Zona")->AsString=Grilla->Cells[ZONA][i];
Dir->Post();
}

if(CodIntTer->Caption.ToInt()>Emp->FieldByName("CodIntTer")->AsInteger){
Emp->Edit();
Emp->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
Emp->Post();
}

DtMdl->DtbsPpal->Commit();

}catch(Exception *E){
DtMdl->DtbsPpal->Rollback();
MostrarMensajeError(E);
}
Grabar->Enabled=false;
ClaIdentif->SetFocus();
}

I use C++ Builder 5 Professional.

Can somebody help me?

Thank you.

Guillermo.

Back to top
Fabio Eduardo Thomaz
Guest





PostPosted: Tue Apr 20, 2004 5:20 pm    Post subject: Re: Error SQL embeded Reply with quote



See the property "UpdateMode" in your TQuery objects.

Change this property to "upWhereKeyOnly".

Regards,

Fabio Eduardo Thomaz
GS/Cash Development Team
Gesplan - Antecipando o futuro de sua empresa
http://www.gesplan.com.br
Rua Xavantes, 54 - Atiradores CEP 89203-900
Joinville/SC - Brasil Tel: 55 47 4380022

Guillermo Díaz wrote:
Quote:
Hi!

In an application, the first time that I record a registration master/detail makes it correctly. But later on, without leaving and without closing the involved files, I am obtaining the following message "Couldn't perform the edit because another user changed the record" when I use Interbase 5.6. But when I use Paradox 7 it seems to work well.

The code is the following one:

void __fastcall TFrmTerceros::GrabarClick(TObject *Sender)
{
int i;

DtMdl->DtbsPpal->StartTransaction();
QryBorrar->ParamByName("Cod")->AsInteger=CodIntTer->Caption.ToInt(); //For to delete the registers details.

try{

if(Ter->FindKey(ARRAYOFCONST((ClaIdentif->Text,Identif->Text))) && Ter->FieldByName("CodIntTer")->AsString==CodIntTer->Caption)
Ter->Edit();
else{
Ter->Append();
Ter->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
}

Ter->FieldByName("ClaIdentif")->AsString=ClaIdentif->Text;
Ter->FieldByName("Identif")->AsString=Identif->Text;
Ter->FieldByName("DigCtrl")->AsString=DigCtrl->Text;
Ter->FieldByName("Nombre")->AsString=Nombre->Text;
Ter->Post();

Dir->Close();
QryBorrar->ExecSQL(); //Delete all records “details”
Dir->Open();

//Eliminación de sucursales sobrantes del Tercero
for(i=1;(i<Grilla->RowCount && !EsVacio(Grilla->Cells[CODSUC][i].c_str()));i++){
Dir->Append();
Dir->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
Dir->FieldByName("CodSuc")->AsString=Grilla->Cells[CODSUC][i];
Dir->FieldByName("NomSuc")->AsString=Grilla->Cells[NOMBRE][i];
Dir->FieldByName("Dir")->AsString=Grilla->Cells[DIR][i];
Dir->FieldByName("Tel1")->AsString=Grilla->Cells[TEL1][i];
Dir->FieldByName("Tel2")->AsString=Grilla->Cells[TEL2][i];
Dir->FieldByName("Fax")->AsString=Grilla->Cells[FAX][i];
Dir->FieldByName("EMail")->AsString=Grilla->Cells[EMAIL][i];
Dir->FieldByName("ApdoAereo")->AsString=Grilla->Cells[APDOAEREO][i];
Dir->FieldByName("Ciudad")->AsString=Grilla->Cells[CIU][i];
Dir->FieldByName("Provincia")->AsString=Grilla->Cells[PROV][i];
Dir->FieldByName("Autonomia")->AsString=Grilla->Cells[AUTONOM][i];
Dir->FieldByName("Pais")->AsString=Grilla->Cells[PAIS][i];
Dir->FieldByName("Zona")->AsString=Grilla->Cells[ZONA][i];
Dir->Post();
}

if(CodIntTer->Caption.ToInt()>Emp->FieldByName("CodIntTer")->AsInteger){
Emp->Edit();
Emp->FieldByName("CodIntTer")->AsInteger=CodIntTer->Caption.ToInt();
Emp->Post();
}

DtMdl->DtbsPpal->Commit();

}catch(Exception *E){
DtMdl->DtbsPpal->Rollback();
MostrarMensajeError(E);
}
Grabar->Enabled=false;
ClaIdentif->SetFocus();
}

I use C++ Builder 5 Professional.

Can somebody help me?

Thank you.

Guillermo.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.