Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Switch remote view between test production databases
Message
 
À
24/07/2008 18:23:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01333911
Message ID:
01334987
Vues:
16
Carlos,

Thank you for your second response, but either I don’t understand it or it doesn’t apply to the way my programs are set up. Let me explain.

FormA is a menu.
It now has code in it, suggested by you, to reset the Connection String. Here’s the code:

*---------------------------------------------------------------------------------------------
*-Init
*
SQLDISCONNECT(0)
CLOSE DATABASES ALL
OPEN DATABASE E:\HarDe
gcCSPROD="DRIVER=SQL Server;SERVER=IW-SQL; UID=IW_rw;PWD=sqlinterc0nnect;APP=Microsoft (R) Visual FoxPro;WSID=C0223;DATABASE=Config;Network=DBMSSOCN"
gcCSTEST="DRIVER=SQL Server;SERVER=TESTSERVER;UID=IW_rw;PWD=sqlinterc0nnect;APP=Microsoft (R) Visual FoxPro;WSID=C0223;DATABASE=Config;Network=DBMSSOCN"
gcCSCURR=DBGETPROP("HarDe","CONNECTION","ConnectString")
*-Determine which drive E:=PROD, T:=TEST
DO CASE
CASE SYS(5)="E:"
DBSETPROP("HarDe","CONNECTION","ConnectString",gcCSPROD)
CASE SYS(5)="T:"
DBSETPROP("HarDe","CONNECTION","ConnectString",gcCSTEST)
OTHERWISE
glAbort=.T.
RETURN
ENDCASE
gcCSCURR=DBGETPROP("HarDe","CONNECTION","ConnectString")
*
*!* *-See what is in the files
*!* *-
*!* SELECT StockCode from rvHarnData ORDER BY stockcode
*!* *
*---------------------------------------------------------------------------------------------

Now this code works great, detecting which drive is in use and setting the connection string accordingly. Thank you by the way.

Then this FormA calls FormB. FormB was built using the wizard, and after it starts up, 1) the data displayed is from the PRODuction (see gcCSPROD above) database and 2) the connection string is set to the TEST database (see gcCSTEST above).

So this means that the FormB is remembering the database used at the time the form was generated using the wizard.

To counter that, I added this code (again from your suggestion) to the FormB INIT method:


*---------------------------------------------------------------------------------------------
*-Init
*
SQLDISCONNECT(0)
CLOSE DATABASES ALL
OPEN DATABASE E:\HarDe
gcCSPROD="DRIVER=SQL Server;SERVER=IW-SQL; UID=IW_rw;PWD=sqlinterc0nnect;APP=Microsoft (R) Visual FoxPro;WSID=C0223;DATABASE=Config;Network=DBMSSOCN"
gcCSTEST="DRIVER=SQL Server;SERVER=TESTSERVER;UID=IW_rw;PWD=sqlinterc0nnect;APP=Microsoft (R) Visual FoxPro;WSID=C0223;DATABASE=Config;Network=DBMSSOCN"
gcCSCURR=DBGETPROP("HarDe","CONNECTION","ConnectString")
*
*-Determine which drive E:=PROD, T:=TEST
DO CASE
CASE SYS(5)="E:"
DBSETPROP("HarDe","CONNECTION","ConnectString",gcCSPROD)
CASE SYS(5)="T:"
DBSETPROP("HarDe","CONNECTION","ConnectString",gcCSTEST)
OTHERWISE
glAbort=.T.
RETURN
ENDCASE
gcCSCURR=DBGETPROP("HarDe","CONNECTION","ConnectString")
*
*-Select from the file we want
SET SAFETY OFF
SELECT StockCode from rvHarnData HAVING RECNO()=1 INTO CURSOR HData
SELECT Hdata
USE
SELECT rvHarnData
GO TOP
WAIT ALLTRIM(StockCode) WINDOW NOWAIT
*
*---------------------------------------------------------------------------------------------

After putting this code in, then FormB operates with the correct database. However an unexpected happening had to be fixed. When called, FormB emitted “alias rvHarnData not found”. To counter that I had to actually use the rvHarnData (remote view) as in the code below. Once I used it, then the form operated normally and with the correct database.

*---------------------------------------------------------------------------------------------
*-Select from the file we want
SET SAFETY OFF
SELECT StockCode from rvHarnData HAVING RECNO()=1 INTO CURSOR HData
SELECT Hdata
USE
SELECT rvHarnData
GO TOP
WAIT ALLTRIM(StockCode) WINDOW NOWAIT
*---------------------------------------------------------------------------------------------

There is only one remaining problem with this seemingly cobbled up approach, the speed is very slow as FormB displays “executing remote… press esc to cancel” for about 30 seconds every time it is called.

Well Carlos, you asked for the code and there it is, I threw in the explanations because I think they are required to explain how things got this way.

I do appreciate your help.

I think the real question is “How can one establish the connection string and the database conditionally at run time in a form created by the wizard?”

Kindest regards,
Bob Pahus
Thanks,
Bob Pahus
Gainesville TX
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform