>*** >*** ADO.PRG >*** > >* PLUCZENIK >* MG 02/02/99 >* Visual FoxPro 06.00.8167.00 for Windows > >#include include\PLUCZ.h > >*** >*** ---------------------------------- >*** > >define class ADO as custom > > cDSN= "" > oConnection= .null. > > * -------------------- > procedure Init() > *-- mg 02/02/99 > if !this.lConnect() > return .f. > endif > > * -------------------- > procedure lConnect() > *-- mg 02/02/99 > private _Err > this.oConnection= createobject("ADODB.Connection") > _Err=0 > this.oConnection.open(this.cDSN) > if _Err=1 > return .f. > endif > > * -------------------- > procedure lSQL(oRS,cSQL) > *-- mg 02/02/99 > private _Err > _Err= 0 > oRS= createobject("ADODB.Recordset") > *-- MG(eds) 09/02/99 - 10:18 > *-- 3 is the cursor type (adOpenStatic) > *-- 4 is the lock type. Not sure which one that is, 3 is optimistic. > > oRS.open(cSQL,this.oConnection,3,4) >* oRS.Cursorlocation= 3 > if _Err= 1 > return .f. > endif > > * -------------------- > procedure Assign(oRS,cField) > LOCAL u > *-- mg 02/02/99 > u= oRS.Fields(cField).Value > return iif(isnull(u),"",u) > > >enddefine > > * -------------------- > procedure cNextAccount(oCountry,oCee) > LOCAL c, o, cLA, cMax, oRS, oC > *-- mg 08/02/99 > oRS= .null. > cLa= ocountry.Cou_AoCode > cMax= oCountry.Cou_AOCode+oCountry.Cou_AOMax > oC= createobject("bzConsignee") > cCeeName= oC.cName(oCee) > cSQL= "select max(laklaco) as lastnumber"+; > " from adressenbestand where laklaco like '"+cLa+"%'"+; > " and laklaco<'"+cMax+"'" > wait window "coucou " + program()+" "+cSql > if !this.lSQL(@oRS,cSQL) > oError.Add_("Selection against AO failed.") > this.nError= 1 > return "" > endif > if oRS.RecordCount<1 > c= cLa+"001" > else > oRS.MoveFirst > c= this.assign(ORS,"LastNumber") > c=cLa+right("000"+alltr(str(val(c)+1)),3) > endif > cSQL= "insert into adressenbestand "+; > "(LaKlaCo,La,Kla,Name,Country,Phone,Fax,Contact) "+; > " values ('"+; > c+"','"+; > left(c,2)+"','"+; > right(c,3)+"','"+; > cCeeName+"','"+; > oCee.cee_Country+"','"+; > oCee.cee_tel+"','"+; > oCee.cee_Fax+"','"+; > oCee.cee_Contact+"')" > if !this.lSQL(@oRS,cSQL) > oError.Add_("Operation against AO failed.") > if oVFP.lIsObject(this.oConnection.Errors) > for each o in this.oConnection.Errors > oError.Add_(o.Description) > endfor > endif > this.nError= 1 > return "" > endif > return c > > >>