Board index » cppbuilder » Problem with TDatabase and TParams

Problem with TDatabase and TParams


2003-10-10 03:20:34 PM
cppbuilder80
Hi,
I've got problem with TDatabase et TParams.
In this code
TParams *Params = new TParams();
hDBICur Cursor;
try {
Params->CreateParam(ftString, "Pr_Code", ptInput);
Params->CreateParam(ftString, "Pr_Caption", ptInput);
Params->Items[0]->AsString=AnsiString(Code);
Params->Items[1]->AsString=Pr_Caption->Text;
SqlCmd="Insert into Project (Pr_Code,Pr_Caption,Pr_BgImage) Values
(:Pr_Code,:Pr_Caption,'N')";
DbMkt->Execute(SqlCmd,Param,false,&Cursor);
} __finally {
delete Params;
}
He says 'I dont find the object' !
Why ?
And how can I use hDBICur
Thank's
 
 

Re:Problem with TDatabase and TParams

Hi pascal!.
try this....: (it's very more easy)
//--------------------------------------------------------------------------
-----
DMVentas->DBVentas->StartTransaction();
TQuery* q = new TQuery();
q->DatabaseName = DMVentas->DBVentas->DatabaseName;
q->SQL->Add("Insert Into Project (Codigo, Nombre) Values (:Codigo,
:Nombre)");
q->Prepare(); // if you execute the insert many times.
try
{
q->ParamByName("Codigo")->AsInteger = 1234;
q->ParamByName("Nombre")->AsString = "Karate y ValeTodo es lo
máximo.";
q->ExecSQL();
DMVentas->DBVentas->Commit();
}
catch(Exception& e)
{
DMVentas->DBVentas->Rollback();
}
//--------------------------------------------------------------------------
-----
Good Luck, Bye!.
"pascal" < XXXX@XXXXX.COM >escribi?en el mensaje
Quote
Hi,

I've got problem with TDatabase et TParams.

In this code

TParams *Params = new TParams();
hDBICur Cursor;

try {
Params->CreateParam(ftString, "Pr_Code", ptInput);
Params->CreateParam(ftString, "Pr_Caption", ptInput);
Params->Items[0]->AsString=AnsiString(Code);
Params->Items[1]->AsString=Pr_Caption->Text;
SqlCmd="Insert into Project (Pr_Code,Pr_Caption,Pr_BgImage) Values
(:Pr_Code,:Pr_Caption,'N')";
DbMkt->Execute(SqlCmd,Param,false,&Cursor);
} __finally {
delete Params;
}


He says 'I dont find the object' !
Why ?

And how can I use hDBICur

Thank's