Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Switch remote view between test production databases
Message
From
24/07/2008 18:23:28
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 7
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01333911
Message ID:
01333931
Views:
13
>Hi folks,
>
>VFP8 form (form A) created with the wizard uses a remote view for source of data.
>It works properly displaying and updating the production database.
>Now I need to make a TEST version and I don't know how to redirect the remote view from one ServerA/Database to ServerB/Database.
>
>I use dbSetProp, in the calling program, to change the connection string but when form A runs it always uses the Production file.
>Can anyone tell me why form A ignores the connection string setting.
>
>Thanks in advance,
>Bob Pahus

Can you post your code?

Just in case are you checking that the value is set? This works for me:
m.lcLocalDatabase 	= "datos"
m.lcLocalConnection = "datos"

m.lcConnectString = "your connect string"

Open Database (m.lcLocalDatabase)
Set Database To (m.lcLocalDatabase)

*!* If we already have an open connection, close it:
If Thisform._SqlHandle > 0 Then
	SQLDisconnect(Thisform._SqlHandle)
Endif

*!* Set local connection properties:
DBSetProp(m.lcLocalConnection, "CONNECTION", "ConnectString", m.lcConnectString)

*!* open shared connection:
Thisform._SqlHandle = SQLConnect(m.lcLocalConnection, .T.)

*!* If runtime, clear connection string:
If Version(2) = 0 Then
	DBSetProp(m.lcLocalConnection, "CONNECTION", "ConnectString", "")
Endif

If Thisform._SqlHandle < 0 Then

	Local lcMessage, lcTitle

	Local Array laError(1)

	= Aerror(m.laError)

	m.lcMessage = ;
		"Error text:      " + CHR(13) + m.laError(2) + Chr(13) + Chr(13) + ;
		"ODBC Error text: " + CHR(13) + m.laError(3) + Chr(13) + Chr(13) + ;
		"ODBC SQL state:  " + CHR(9) + m.laError(4) + Chr(13) + ;
		"ODBC Error #:    " + CHR(9) + Transform(m.laError(5)) + Chr(13) + ;
		"ODBC Handle:     " + CHR(9) + Transform(m.laError(6))

	m.lcTitle = "Error # " + Transform(m.laError(1))

	Messagebox(m.lcMessage, 0 + 16, m.lcTitle)
Endif
In this code, all the views use a shared connection. This connection is opened at program start and closed at program end. You do not need to do that.

The ConnectString parameters are stored somewhere, in registry or setting file, not shown here.

The ConnectString is removed from the dbc connection after the connection has been established, to keep it private. You do not need to do that.

Maybe you should check the value of the connection ConnectString property after you set it:
wait DbGetProp(m.lcLocalConnection, "CONNECTION", "ConnectString") window
Carlos Alloatti
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform