 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Barry Guest
|
Posted: Fri May 13, 2005 4:53 pm Post subject: Wedservice and ADO |
|
|
I'm trying to write a function that will simply validate a case number using
a webservice and ADO. My question is I want to create the ado connection
and ado query but I'm not sure when I specify create what should go between
the (). See below code. Any help would be appreciated.
function TTemperature.validateCaseNumber(CaseYear: Smallint;
CaseNumber: Integer): Boolean;
var
adocon : TADOConnection;
adosql : TSQLQuery;
begin
try
adocon := TADOConnection.Create(adocon); <== Is this the
correct way to create a object?
adosql := TSQLQuery.Create(adosql);
adocon.LoginPrompt := false;
adocon.ConnectionString := 'Provider=MSDASQL.1;Persist Security
Info=False;Data Source=ecf_live';
adosql.SQL.Add('select cs.cs_year, cs.cs_number');
adosql.SQL.Add('from case cs');
adosql.SQL.Add('where cs.cs_year = '+inttostr(CaseYear)+' AND');
adosql.SQL.Add('cs.cs_number = '+inttostr(CaseNumber));
adosql.Active := true;
if adosql.RecordCount > 0 then result := True else result := False;
finally
adocon.Free;
adosql.Free;
result := False;
end;
end;
|
|
| Back to top |
|
 |
danny heijl Guest
|
Posted: Fri May 13, 2005 7:17 pm Post subject: Re: Wedservice and ADO |
|
|
Barry schreef:
| Quote: | adocon := TADOConnection.Create(adocon); <== Is this the
correct way to create a object?
|
Just use Nil as the owner :
adocon := TADOConnection.Create(Nil);
The owner (a TComponent descendant) is responsible for destroying the
compinent when it is itself destroyed, in your case there is no owner,
and you free the object yourself, so you should pass Nil.
Danny
---
|
|
| Back to top |
|
 |
|
|
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
|
|