Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error returned from a method in an instantiated VB .DLL
Message
 
 
To
07/04/2002 12:55:41
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00639448
Message ID:
00641963
Views:
16
The GetRows method returns an array and that maybe confuses VFP. Does it works if you pass parameter that causes GetGeoName() method to return empty value? If it does, than try to convert the value returned by rsData.GetRows() to the string first and return that string.

>>Did you try to test it in VB to make sure that it works? Can you post relevan code from GetGeoName() method?
>>
>>>I've been away from VFP for too long :(
>>>
>>>I am trying to return a value from a SQL Server database via an instantiated VB .DLL.
>>>
>>>A snippet of the code is:
>>>oGroups = CREATEOBJECT("MIPS_Groups.clsGroups")
>>>IF VARTYPE(oGroups) = "O" AND NOT ISNULL("oGroups")
>>>x = oGroups.GetGeoName("010")
>>>ENDIF
>>>
>>>The method should return a state name; i.e., "Georgia". The VB code uses the oRecordSet.GetRows() method to return the result.
>>>
>>>I'm getting the error:
>>>OLE IDispatch exception error code 0 from ADODB.Errors; Item cannot be found in the collection corresponding to the requested name or ordinal ...
>>>
>>>In the above example, should x be an array element rather than a variable?
>>>
>>>Bottom line, what am I doing wrong?
>>>
>>>Thanks,
>>>
>>>Dan Rhymes
>
>Sergey,
>
>Thanks for replying. We use this method in our Executive Information web application; i.e., calling it though an ASP. And we have no problem. What am I missing when I try to call it in VFP? I've pasted the VB source code below:
>
>Public Function GetGeoName(Geo_Code AS Variant) AS Variant
>	
>	Dim strSQL AS string
>	Dim Array_Geo AS Variant
>	Dim rsData AS New ADODB.RecordSet
>	
>	On Error GoTo ErrorHandler
>	
>	OpenConnection
>	
>	strSQL = " SELECT DISTINCT geographic.name 
>               FROM geographic 
>                WHERE geographic.geo_code = '" & Geo_Code & "' "
>	
>	rsData.CursorType = adOpenForwardOnly
>	rsData.ActiveConnection = CONNECT_OBJ
>	rsData.Open strSQL
>	
>	If rsData.EOF Then
>		GetGeoName = ""
>	Else
>		GetGeoName = rsData.GetRows()
>	End If
>	
>	rsData.Close
>	Set rsData = Nothing
>	CloseConnection(True)
>	
>	Exit Function
>	
>ErrorHandler:
>	With Err
>		Call LogNTEvent("MIPS_Groups.DLL",
>.Number,.Description & 
>". Occurred in GetGeoName().",EVENTLOG_ERROR_TYPE)
>	End With
>	GetGeoName = CONNECT_OBJ.Errors.Item(0).NativeError
>	rsData.Close
>	Set rsData = Nothing
>	CloseConnection(True)
>End Function
>
>Thanks,
>
>Dan
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform