Delphi 7 object undefinedat -


i have web service have created using delphi , want connect sql server have added project ado connection , adoquery had both of them configured , ready use, there small problem, there 2 units on project , objects added unit1 , working implunit whitch unit, , can`t find way reference or include 1 unit inside other unit.

unit1

  { soap webmodule}  unit unit1;  interface  uses   sysutils, classes, httpapp, invokeregistry, wsdlintf, typinfo,   webservexp, wsdlbind, xmlschema, wsdlpub, soappasinv, soaphttppasinv,   soaphttpdisp, webbrokersoap, db, adodb;  type   twebmodule1 = class(twebmodule)     httpsoapdispatcher1: thttpsoapdispatcher;     httpsoappascalinvoker1: thttpsoappascalinvoker;     wsdlhtmlpublish1: twsdlhtmlpublish;     adoconnection1: tadoconnection;     adodataset1: tadodataset;     adoquery1: tadoquery;     procedure webmodule1defaulthandleraction(sender: tobject;       request: twebrequest; response: twebresponse; var handled: boolean);   private     { private declarations }   public     { public declarations }   end;  var   webmodule1: twebmodule1;  implementation  {$r *.dfm}  procedure twebmodule1.webmodule1defaulthandleraction(sender: tobject;   request: twebrequest; response: twebresponse; var handled: boolean); begin   wsdlhtmlpublish1.serviceinfo(sender, request, response, handled); end;  end. 

my unit

   unit utimplementacao;  interface  uses   invokeregistry,db, adodb;   type     iinterface = interface(iinvokable)     ['{eff30ffa-da0c-433a-832a-0ba057b55103}']     function receiveuser(username : string; password : string) :     boolean; stdcall;   end;      timplementacao = class(tinvokableclass, iinterface)     public     function receiveuser(username : string; password : string) :     boolean; stdcall;    end;  implementation  { timplementacao }  function timplementacao.receiveuser(username, password: string): boolean; var  adoconnection1: tadoconnection;  adoquery1: tadoquery; begin     try       adoconnection1 := tadoconnection.create(nil);       adoconnection1.loginprompt := false;       adoconnection1.connectionstring:= 'provider=sqloledb.1;integrated security=sspi;' +                                         'persist security info=false;' +                                         'user id=diego;'+                                         'catalog=onlineshopping;' +                                         'data source=diego-pc\sqlexpress'+                                         ';use procedure prepare=1;' +                                         'auto translate=true;packet size=4096;'+                                         'workstation id=diego-pc;'+                                         'use encryption data=false;'+                                         'tag column collation when possible=false;';       adoconnection1.connected := true;       adoquery1.connection := adoconnection1;       adoquery1.sql.add('select username,upassword users '+                       'where  username = :usernamep , upassword = '+                       ':upasswordp');       adoquery1.parameters.parambyname('upasswordp').value := password;       adoquery1.parameters.parambyname('usernamep').value  := username;       adoquery1.execsql;        result := true;    adoquery1.free;   if adoconnection1.connected     adoconnection1.close;     adoconnection1.free;   end;    result := false;  end;  initialization   invregistry.registerinvokableclass(timplementacao);   invregistry.registerinterface(typeinfo(iinterface));  end. 

please disregard adoconnection , adoquery have added unit got little desperate ad duplicade code... yeah, know yachs!!!!

@silverwarrior

if declare unit1 inside uses of utimplementacao have access componemts below:

type     adoconnection1: tadoconnection;         adodataset1: tadodataset;         adoquery1: tadoquery; 

or should declare each 1 of types variable inside var clause ?

if want access objects declared in unit1 other units in project need add unit1 interface uses section (the 1 @ top) of units.

unit implunit;  interface  uses   sysutils, classes, ... , unit1;  ... 

that same way delphi automatically adds other units sysutils, classes, etc.

also recomend change name of unit somethng more meaningfull when looking @ code after time know code unit contains , used for.

edit: based on edit of question suspect want acces components unit1 directly calling:

unit1.adoconnection1 

that won't work. why? becouse components declared within scope of twebmodule1 class.

so need access them this:

unit1.webmodule1.adoconnection1; 

note: if unit1 added interface uses section of utimplementacao unit can directly call:

webmodule1.adoconnection1 

you don't have prefix every command unit1. have written in such way more understandable unit mebers accessing. other people might reading thread , not knowing structure of program.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -