Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP8 and COM+. It's sad...
Message
De
08/07/2003 18:55:56
 
 
À
08/07/2003 15:44:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00807913
Message ID:
00808266
Vues:
15
Aleksey, George,

I certainly don't mean to butt in here, but since you have asked for some
code to be posted I'll be glad to provide my dll.
To clarify, I am no longer getting any C05 errors....just the inability
to register the DLL compiled with VFP8. The VFP7 code registers fine.
I'm registering with Regsvr32 to a Win2k server running IIS.

I've been playing with the VFP8 version of this dll, adjusting the packetsize per Microsoft KnowledgeBase articles.

Here is my code:
*This entirely self-contained program will build a COM server
* called "CODEMAKER.DLL" containing the Function MAKECODE.
* It will unregister a prior instance, if any
* MakeCode is called with this SYNTAX:
*  NewCode = CREATEOBJECT("CODEMAKER.CODEMAKER") && create the server object
* ?NewCode.MakeCode("LNK") && Returns a new Unique code value

* Since this program creates and compiles, it's gotta be named:
IF PROGRAM() != "CODEMAKER"
   ?"this file MUST BE NAMED 'CODEMAKER.prg'"
   RETURN
ENDIF

* If CodeMaker is currently registered, unregister it before we begin
IF FILE("CODEMAKER.DLL")
   DECLARE INTEGER DllUnregisterServer IN CODEMAKER.DLL
   DllUnregisterServer()
   CLEAR DLLS
ENDIF

BUILD PROJECT CodeProj FROM CODEMAKER

BUILD DLL CODEMAKER FROM CodeProj recomp

DEFINE CLASS CODEMAKER AS SESSION OLEPUBLIC

FUNCTION MakeCode && UDF TO GENERATE UNIQUE CODE
* PROC MakeCode && UDF TO GENERATE A UNIQUE CODE
*..................................................................
* The mWhereFrom parameter is passed to MakeCode by the requesting
* program and identifies which record in Ucodes to interact with.
* eg, for creating the UserLinkID, mWhereFrom = 'USR',
* for creating the FormLinkID, mWhereFrom = 'FRM'
* MakeCode finds the appropriate Ucodes record, extracts it using
* an SQL SELECT, creates the next sequential KeyValue, updates
* the Ucodes record with the new value, then returns the new value
* to the calling program.
* If NO value is passed, it's considered to be a GENERAL KeyName, so
* MakeCode will use the Ucodes General record.  drk 7/7/03
*..................................................................
PARAMETERS mWhereFrom
IF PARAMETERS()=0
   mWhereFrom = "GENERAL"
ENDIF

* Clean up the parameter.
mWhereFrom = UPPER(ALLTRIM(mWhereFrom))

*..................................................................
* If we're compiling in VFP8, force SQL to behave like VFP7 SQL.
IF "08"$VERSION()
   SET ENGINEBEHAVIOR 70
ENDIF
*..................................................................

* Create the connection to a DSN
rsConnect =SQLSTRINGCONNECT('dsn=RushMaster;uid="";pwd=""')

* Select statement: Variables must have "?" in front of varname
quest1 = "SELECT * FROM UCODES WHERE KEYNAME = ?mWhereFrom"

* Set processing to synchronous
= SQLSETPROP(rsConnect, 'asynchronous', .F.)
= SQLSETPROP(rsConnect, "PacketSize", 2048 )
* = SQLSETPROP(rsConnect, 'DispWarnings', .T.)

* Execute the query, put the results in a cursor named myCursor
ConChk = SQLEXEC(rsConnect,quest1,'myCursor')
*..................................................................

* Incriment the LastKeyVal field of the cursor, create a variable
mNewCode = ALLTRIM(STR(VAL(myCursor.LastKeyVal)+1))

*..................................................................
* Create and execute an update string for the specified ucodes.LastKeyVal field
quest2="UPDATE UCODES SET LastKeyVal = ?mNewCode WHERE KEYNAME = ?mWhereFrom"
= SQLEXEC(rsConnect,quest2,'myCursor')
= SQLCOMMIT(rsConnect)

* Create and execute an update string for the specified ucodes.CodeDate field
quest3="UPDATE UCODES SET CodeDate   = DATETIME() WHERE KEYNAME = ?mWhereFrom"
= SQLEXEC(rsConnect,quest3,'myCursor')
= SQLCOMMIT(rsConnect)
*..................................................................

* Close the DSN connection
= SQLDISCONNECT(rsConnect)

*..................................................................
* Create the final MakeCode Return Value. If a parameter was passed to MakeCode,
* eg, 'LNK', prepend it to the mNewCode Value, 
* ie, 'LNK'+'10000254' ='LNK10000254'.
* If NO value was passed, it's considered to be a GENERAL KeyName, 
* so return JUST the new mNewCode Number String: '10000254'
IF mWhereFrom # 'GENERAL'
   mNewCode = mWhereFrom+mNewCode
ELSE
   mNewCode = mNewCode
ENDIF

RETURN(mNewCode)

ENDDEFINE
************************************************************************
Thanks,

David
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform