Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# and COM
Message
From
24/08/2001 15:17:00
Raymond Humphrys
Michigan Department of Community Health
Bath, Michigan, United States
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
00548530
Message ID:
00548907
Views:
17
I'm getting OLElDispatch error code 173 [time] error #1 when I try to open a file using your line oVFP.myDoCmd("use c:\temp\sometable") && use a sample table somewhere


any idea what this means?


thanks,

>>Are there any examples floating around how to do this?
>>
>>
>>>>Is it possible to access a VFP table from a dll written using C#, that can
>>>>pull records out of a table, delete them, and then pack the table?
>>>>
>>>>thanks
>>>
>>>You can create VFP Automation server that'll perform all those operations and use it from your C# program.
>
>Hi Raymond,
>
>Basically you do the following:
>Create a program VFPServer.PRG
>
>* VFPServer.PRG
>
>DEFINE CLASS myVFPServer1 AS SESSION OLEPUBLIC
>	DATASESSION = 2	&& set private datasession
>PROCEDURE INIT()
>	SYS(2335,0) && set unattended mode
>ENDPROC
>	
>PROCEDURE myDoCmd(tcCmd)
>	&tcCmd	&& execute whatever VFP command is passed
>ENDPROC
>
>PROCEDURE ERROR
>	LPARAMETERS nError, cMethod, nLine
>	#DEFINE CRLF  CHR(13) + CHR(10)
>	LOCAL lcErrorMessage
>	* Append to error log file
>	lcErrorMessage = TRANSFORM(DATETIME()) + CRLF + ;
>		THIS.NAME + CRLF + ;
>		"Error Number   : " + TRANSFORM(nError) + CRLF + ;
>		"Method         : " + cMethod + CRLF + ;
>		"Line           : " + TRANSFORM(nLine) + CRLF + ;
>		"Message        : " + MESSAGE()+ CRLF
>	STRTOFILE(lcErrorMessage, "error.txt", .T.)
>	* Notify the client
>	COMRETURNERROR(THIS.NAME, lcErrorMessage)
>ENDPROC
>
>PROCEDURE myEval(tcExpr)
>	RETURN EVAL(tcExpr)	&& evaluate the parameter, assuming it is  a valid VFP expression
>ENDPROC
>
>ENDDEFINE
>
>
>Then, from the Command window:
>
>BUILD PROJECT VFPserver FROM VFPServer
>BUILD EXE VFPserver FROM VFPserver
>
>oVFP = CREATEOBJECT("VFPserver.myVFPserver1")	&& create the VFP automation server object
>oVFP.myDoCmd("use c:\temp\sometable") && use a sample table somewhere
>?oVFP.myEval("'Table contains ' + TRANSFORM(RECCOUNT())")	&& get the record count
>*This sample intended for VFP test. For C# you just use the appropriate syntax to instantiate this VFPServer and call its functions.
>
>
>Note, that EXE COM server starts in the directory where VFP runtime is, so you have to set path to your directory where DBF is or use full path filename.
>
>vfpServer.Error() method will return you any errors which may happen in your COM server.
>
>Be careful with this server, it may execute any command for you, for example
>oVFP.myDoCmd("DELETE FILE c:\*.*") && DON'T DO THIS!!!
>:)
Some days it's not worth chewing through the leather straps ...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform