Rick
In my module MAIN open the connection to the database. The variable connection (oConex) is public and I see all the sections, part I check that the connection is not closed. Below I'll put as the connection to the database.
The problem is that when trying to open the recordset, this does not open, FW_OpenRecordSet function (StringConect, Source, LokType) returns nil, so the recordset failed to create, and this is because the SQL statement to opening. Perhaps the issue is given by the type of field in the table, and there is no way to change it, go try it today start date and end date to TimeStamp to see if that way is created recordset.
This function is performed only choose the work area, the database with which we will work, because this program works with multiple databases.
Each work area is in a different folder
I hope you forgive me for using the Google translator
- Code: Select all Expand view
Function Main()
Local aCorH[2]
Local hDlib
Local oBtnBal1,oBtnBal2,oBtnBal3,oBtnBal4,oBtnBal5
Local oPopBal1,oPopBal2,oPopBal3,oPopBal4,oPopBal5
Public oWMain, oFont,oIcon,oConex
Public cAreaTemp, cArea := "", aDatEmp[0],cTrabajo,aIva[7,3]
...........................................
DEFINE WINDOW oWMain MDI FROM 02, 02 TO ( MaxRow() - 2 ), ( MaxCol() - 10 );
.............................................
ACTIVATE WINDOW oWMain MAXIMIZED ;
ON INIT (EscogeArea(),VerificaConfig()) ; //<-----------------EscogeArea is where you choose the work area
.........................................................
*===============================================================================
function EscogeArea()
*===============================================================================
....................................
DEFINE DIALOG oDlgEmp RESOURCE "INICIO";
COLOR RGB(0,0,0), RGB(153,204,255)
REDEFINE BITMAP oBmp ID 101 OF oDlgEmp ;
FILENAME ".\BMP\LOGO2.BMP" ;
ADJUST;
UPDATE;
TRANSPARENT
REDEFINE BUTTONBMP ID 301 OF oDlgEmp BITMAP "ACEPTAR" TEXTRIGHT;
ACTION lSeguir := PonArea(oDEmpr,oLbx,oDlgEmp)
oLbx := TXBrowse():New(oDlgEmp)
.....................................................
for nFor := 1 to len(aCols)
oLbx:aCols[ nFor ]:blDClickData := {|| (lSeguir := PonArea(oDEmpr,oLbx,oDlgEmp),oLbx:Refresh()) }
oLbx:aCols[ nFor ]:bRClickData := {|| (lSeguir := PonArea(oDEmpr,oLbx,oDlgEmp),oLbx:Refresh()) }
oLbx:aCols[ nFor ]:bRClickHeader := {|r,c,f,o| NIL }
next
.................................................................
//----------------------------------------------------------------------------//
function PonArea(oDEmpr,oLbx,oDlgEmp)
//----------------------------------------------------------------------------//
Local cCarpeta, cEstacion
Local cDir := cArea
Local cSitio,lSeguir
Sysrefresh()
ASIZE(aDatEmp, EMP->( FCOUNT() ) )
AFILL(aDatEmp,.T.)
EMP->( IniCampo(@aDatEmp) )
EMP->( TabCampo(@aDatEmp,0) )
cEstacion := NetName(.t.)
cCarpeta := cDir+"\"+cEstacion
cSitio := cDir+"\"+oDEmpr:Codigo+"\"
cArea := cSitio
cAreaTemp := cCarpeta
cNomArea := oDEmpr:Nombre+" "+Str(oDEmpr:Ejercicio)
cTrabajo := "[ "+oDEmpr:codigo+" "+oDEmpr:nombre+" ]"
oWMain:SetText("Gestión Comercial "+cTrabajo)
oWMain:Refresh()
Set Path to (cArea)
Set Default to (cArea)
cEjercicio := Str(oDEmpr:Ejercicio)
lSeguir := AbreTablas() //<<=========================Here
If lSeguir
CARGAIVA()
EndIf
oLbx:Destroy()
oDlgEmp:End()
Return( lSeguir )
*-------------------------------------------------------------------------------
FUNCTION AbreTABLAS()
*-------------------------------------------------------------------------------
Local cServer := "localhost"
Local cUser := "root"
Local cPass := ""
Local lConecta := .T.
Local cSource := cArea+"Datos.mdb"
* Para aplicaciones en MySQL
* oConex := TOLEAUTO():new("adodb.connection")
* oConex:ConnectionString:="Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=LBRINQUIS;User='root'; Password='';Option=3;"
* TRY
* oConex:Open()
* MSGINFO("CONECTADO")
* CATCH
* MSGSTOP("NO SE CONECTO")
* RETURN NIL
* END
* Para aplicaciones con ACCES
* oConex := TOLEAUTO():NEW("ADODB.connection")
oConex := CREATEOBJECT("ADODB.connection")
oConex:open("Provider= MicroSoft.Jet.OLEDB.4.0;Data Source="+cSource+";")
If Empty(oConex)
MsgAlert(" No se Pudo Establecer la Conexion Con La Base De Datos..","Atencion")
lConecta := .F.
EndIf
If lConecta
* AbreBrochas()
EndIf
Return(lConecta)
Failure to connect to the database the program does not continue, if you disconnect the program ends