Mega Code Archive

 
Categories / Delphi / Examples
 

Ibo&asp

Title: ibo&asp Question: after reading at matlus.com how play nice with asp objects i wanted to do the same thing with the ibobjects Answer: here i show where to get those ideeas and how i made it it 's like vbscript way of using the record set because that was more simple to others to use it here we go unit Main; interface uses ComObj, ActiveX, AspTlb, Ibo_TLB, StdVcl; type Tibdataset = class(TASPObject, Iibdataset) protected procedure OnEndPage; safecall; procedure OnStartPage(const AScriptingContext: IUnknown); safecall; procedure connect(const dbName, user, passwd: WideString; dialect: Shortint); safecall; procedure sqlquery(const sqlstring: WideString); safecall; procedure movenext; safecall; function Get_eof: WordBool; safecall; function Get_fieldname(const fieldname: WideString): OleVariant; safecall; procedure Set_disconnect(Value: WordBool); safecall; procedure disconnectdb; safecall; function Get_recordcount: Integer; safecall; procedure first; safecall; procedure last; safecall; end; implementation uses ComServ, dmMainUnit; var dm: TdmMain; procedure Tibdataset.OnEndPage; begin inherited OnEndPage; end; procedure Tibdataset.OnStartPage(const AScriptingContext: IUnknown); begin inherited OnStartPage(AScriptingContext); dm := TdmMain.Create(nil); end; procedure Tibdataset.connect(const dbName, user, passwd: WideString; dialect: Shortint); var text: string; begin with dm do begin db.DatabaseName := string(dbName); db.Username := string(user); db.Password := string(passwd); db.SQLDialect:=dialect; try db.Connect; // text := 'connected Ok'; except text := 'There was an error connecting'; end; end; response.Write(text); end; procedure Tibdataset.sqlquery(const sqlstring: WideString); var text: string; begin with dm do begin qMain.Close; qMain.SQL.Clear; qMain.SQL.Add(string(sqlstring)); try qMain.Open; // text := 'Open'; except text := 'Please execute the query first'; end; end; response.Write(text); end; procedure Tibdataset.movenext; begin try dm.qMain.next; except end; end; function Tibdataset.Get_eof: WordBool; begin result := dm.qMain.eof; end; function Tibdataset.Get_fieldname(const fieldname: WideString): OleVariant; begin result := dm.qMain.FieldByName(string(fieldname)).AsVariant end; procedure Tibdataset.Set_disconnect(Value: WordBool); begin dm.db.Connected:=not value; end; procedure Tibdataset.disconnectdb; begin dm.db.Disconnect; end; function Tibdataset.Get_recordcount: Integer; begin result:=dm.qMain.RecordCount; end; procedure Tibdataset.first; begin dm.Qmain.first; end; procedure Tibdataset.last; begin dm.qMain.Last; end; initialization TAutoObjectFactory.Create(ComServer, Tibdataset, Class_ibdataset, ciMultiInstance, tmApartment); end.