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) EndifIn 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.
wait DbGetProp(m.lcLocalConnection, "CONNECTION", "ConnectString") windowCarlos Alloatti