Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The oApp value sometimes does not log in
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01685542
Message ID:
01685558
Views:
27
>>>>Hi,
>>>>
>>>>I am trying to figure out why a log file sometimes does not have a certain value.
>>>>
>>>>Here is an example:
>>>>In some programs (.prg), to check if the connection to SQL Server is valid, the code calls the application object property conn_handle. As this:
>>>>
>>>>oApp.conn_handle_source = 5 && or a different number depending on where the check is made)
>>>>=oApp.conn_handle
>>>>
>>>>
>>>>In the application class, when the call to oApp.conn_handle is made (via =oApp.conn_handle), the following method is fired: PROCEDURE conn_handle_access
>>>>This method (conn_handle_access) checks the connection. And if it is good, the following entry is logged:
>>>>
>>>>local cCalledFrom
>>>>cCalledFrom = "" 
>>>>IF this.conn_handle_source > 0
>>>>    cCalledFrom = " Called From " + ALLTRIM(STR(this.conn_handle_source))
>>>>ENDIF 
>>>>		
>>>>LOCAL ARRAY aStackArray[1,1]
>>>>ASTACKINFO(aStackArray)
>>>>cCalledFrom = CHR(13) + CHR(10) + SPACE(22) + cCalledFrom + " Program: " + aStackArray[alen(aStackArray,1)-1,2] + " Module: " + aStackArray[alen(aStackArray,1)-1,3]
>>>>
>>>>STRTOFILE( TTOC(DATETIME()) + " oApp.conn_handle_access(). " + cCalledFrom +  CHR(13) + CHR(10), cLogFilePath + cLogFileName, 1 )
>>>>
>>>>
>>>>
>>>>The problem is that sometime the .log file does not have the "Called From #" but only "Program:.... "
>>>>As if the value in property this.conn_handle_source is 0 (zero). But I check the code and a value (a number) is always assigned.
>>>>Why would the it not be in the log file?
>>>>Anybody see something wrong with the code above?
>>>>
>>>>TIA
>>>
>>>I found something that maybe causing the problem I described above. But I need to clarify something:
>>>I have this function:
>>>
>>>
>>>FUNCTION GetSqlConnectHandle
>>>RETURN oApp.conn_handle
>>>
>>>
>>>Does the code above, RETURN oApp.Conn_handle fires the method oApp.conn_handle_access?
>>>
>>>TIA
>>
>>Hi,
>>
>>Yes.
>>
>>MartinaJ
>
>Thank you, Martina! This could be a cause of many problems. Now I just need to find a rope lol

I have a question of good practice. As Martina confirmed, I get a lot of "unnecessary" calls to the method oApp.conn_handle_access. These calls do nothing but there are a lot of them. I tested the app and these calls do not seem to add a time to the program execution.
My question: Should I do away with this method oApp.conn_handle_access and create some "custom" function to check the connection to the SQL Server? Or, "unnecessary/multiple" call are not creating a problem?

TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform