Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Question about the Open() method in wwBusiness

$
0
0
Re: Question about the Open() method in wwBusiness
West Wind Client Tools
Re: Question about the Open() method in wwBusiness
12/03/2011
07:32:40 AM
3DI0G67XY Show this entire thread in new window
From:
To:
Attachments:
None
>Wouldn't you want to consistently use the business object for all data access instead of mixing table access in with your user interface anyway?


Yes, you are correct about this... It's a fair and constructive question. And in most cases, I do exactly that, since it is the best practice.

However, I am in the process of migrating my app to wwBusiness (about 80% complete), so I still have a few cases where there is a mixture of good BO practices, and a few old-school things going on in my forms.

So, my suggested fix would eliminate the issue for those apps that are not perfectly in the BO camp yet, without causing any problems for the pure BO world.

I'm hoping Rick will comment... Haven't heard from him yet.

Sure, I can change the code on my end, but I try to never alter the wwBusiness code at all.


Ahh. I understand the dilemma now. I guess it would help if I paid better attention to what you said in your inital post!

Wouldn't you want to consistently use the business object for all data access instead of mixing table access in with your user interface anyway? Seems like that would be one solution to this type of situation while having the side effect of compartmentalizing your data access and UI code.

Just another thought (and hopefully a better one than the last!).

Marty

My app runs with Set Exclusive Off

That's not the issue... It has to do with using the table once for one purpose (say a grid on a FoxPro form), and then trying to use it again for another purpose, but under a different alias.

You have use the AGAIN keyword on the USE statement the any time you try to use the table a second time in a data section.

Hey Matt,

I get around this in my desktop apps by setting Exclusive off. WebConnection has this as a requirement so I started adopting that thinking too.

Just a thought,

Marty

Rick - I hit a problem with the Open() method on the wwBusiness class today. I am using the class with FoxPro DBF tables and a desktop app.

The issue I had was that the form I was using had already USED the DBF table under an alias that was different than the DBF filename, and then I created a wwBusiness object, and when its Open() method was called, it tried to USE the table also, but failed, because the table was already being used, but under a different alias.

To me it seems like the Open() method should use the AGAIN keyword to prevent this error from happening.

Like this:

USE ( THIS.cDataPath + lcFile ) AGAIN ALIAS (lcAlias)


Here is the code from your class:

LPARAMETER lcFile, lcAlias, llForceReconnect LOCAL lcConnectString lcFile=IIF(!EMPTY(lcFile),lcFile,THIS.cFileName) *** Nothing passed and no MasterTable - exit IF THIS.nDataMode = 0 AND EMPTY(lcFile) RETURN .F. ENDIF DO CASE CASE THIS.ndatamode = 0 lcAlias=IIF(!EMPTY(lcAlias),lcAlias,THIS.cAlias) IF !EMPTY(lcFile) AND UPPER(lcFile) == UPPER(THIS.cFileName) THIS.cAlias = lcAlias ENDIF IF USED(lcAlias) SELE (lcAlias) ELSE SELE 0 USE ( THIS.cDataPath + lcFile ) ALIAS (lcAlias) IF !USED(lcAlias) THIS.seterror("Unable to open " + THIS.cFileName) RETURN .F. ENDIF ENDIF






Viewing all articles
Browse latest Browse all 10393

Trending Articles