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 

Wedservice and ADO

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi XML
View previous topic :: View next topic  
Author Message
Barry
Guest





PostPosted: Fri May 13, 2005 4:53 pm    Post subject: Wedservice and ADO Reply with quote



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





PostPosted: Fri May 13, 2005 7:17 pm    Post subject: Re: Wedservice and ADO Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi XML 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.