In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Error en apertura de archivos

Foro de Xailer profesional en español
Responder
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Error en apertura de archivos

Mensaje por Daniel Pechir »

Hola a todos

Ya logré conectarme en mi sitio web
Sin embargo no me quiere funcionar el query con el siguiente código:

IF :lConnected
MsgInfo( 'Conectado a '+cDatabase, 'Aviso' )

WITH OBJECT ::oPrueba
:cSelect := "select * from Empresa where Nombre <> ''"
:nCursorType := adOpenDynamic
:nLockType := adLockOptimistic
:cProcess := 'GENERAL'
IF :lOpen
:Close()
ENDIF
IF !:lOpen
:lOpen:= .T.
IF !:lOpen
MsgStop( "ERROR: No es posible abrir el archivo Empresa", "Error de conexion.." )
RETURN NIL
ENDIF
ENDIF
:lReadOnly := .F.
IF :RecCount() > 0
MsgInfo( 'Tengo Datos' )
ENDIF
END


::oGo:lEnabled := .T.
::oGo:SetFocus()

ELSE
MsgAlert( ' No se logró la Conexión ', 'Aviso' )
::oGo:lEnabled := .F.
::oAbort:SetFocus()
ENDIF

Se conecta
Muestra un SHOWDATABASES
Inclusive si se le pide un GetTables las muestra, pero se atota con el query
img 2.png
img 2.png (17 KiB) Visto 1061 veces
img 4.png
img 4.png (14.66 KiB) Visto 1061 veces
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: Error en apertura de archivos

Mensaje por Daniel Pechir »

img 2.png
img 2.png (17 KiB) Visto 1052 veces
img 3.png
img 3.png (15.26 KiB) Visto 1052 veces
img 5.png
img 5.png (18.92 KiB) Visto 1052 veces
Daniel Pechir
Mensajes: 191
Registrado: Vie Mar 15, 2013 12:32 am

Re: Error en apertura de archivos

Mensaje por Daniel Pechir »

Les comparto el código con el que pude abrir una tabla

IF ::oSQLTable1:lOpen
::oSQLTable1:Close()
ENDIF

cDatabasesel := "`" + ::oListbox1:aItems[ ::oListbox1:nIndex ] + "`"

WITH OBJECT ::oMaria

cDatabase := cDatabasesel
cHost := xxxxxxxxxx
cPassword := xxxxxxxxxx
cUser := 'dapesist_daniel'

cServer := cHost

IF ! ::oMaria:Connect()
MsgStop( "NO ES POSIBLE REALIZAR LA CONEXION CON EL SERVIDOR DE DATOS" + Hb_OsNewLine() + ;
"POR FAVOR, REVISE SUS CONEXIONES DE RED...")
QUIT
RETURN NIL
ELSE
MsgInfo( 'Conectado a '+cDatabase, 'Aviso' )
ENDIF

cMsgError:= "NO FUE POSIBLE CREAR LA BASE DE DATOS DEL SISTEMA, POR FAVOR VERIFIQUE" + HB_OsNewLine()+;
"QUE LAS CONEXIONES DE RED O DE INTERNET ESTE HABILITADAS"

cCmdQuery:= "CREATE DATABASE IF NOT EXISTS " + ALLTRIM( cDataBase )

IF !::oMaria:Execute( cCmdQuery )
MsgStop( cMsgError )
QUIT
RETURN NIL
ENDIF

cMsgError:= "NO FUE POSIBLE ABRIR LA BASE DE DATOS DEL SISTEMA, POR FAVOR VERIFIQUE" + HB_OsNewLine()+;
"QUE LAS CONEXIONES DE RED O DE INTERNET ESTE HABILITADAS"

cCmdQuery := "USE " + ALLTRIM(cDataBase)

IF !::oMaria:Execute( cCmdQuery )
MsgStop( cMsgError )
RETURN NIL
ENDIF

//-------------- INICIA APERTURA DE TABLAS --------------- //

If !::oMaria:Execute("SET SESSION wait_timeout=28880")
MsgStop( "ERROR AL INTENTAR ESTABLECER LA VARIABLE <wait_timeout>",'Error de conexión')
Application:Terminate()
Endif

If !::oMaria:Execute("SET SESSION interactive_timeout=28880")
MsgStop( "ERROR AL INTENTAR ESTABLECER LA VARIABLE <interactive_timeout>",'Error de conexión')
Application:Terminate()
Endif

If !::oMaria:Execute("SET SESSION sql_big_selects=1")
MsgStop( "ERROR AL INTENTAR ESTABLECER LA VARIABLE <sql_big_selects=1>",'Error de conexión')
Application:Terminate()
Endif

If !::oMaria:Execute("SET @lower_case_table_names=1")
MsgStop( "ERROR AL INTENTAR ESTABLECER LA VARIABLE <set @lower_case_table_names=1>",'Error de conexión')
Application:Terminate()
Endif

If !::oMaria:Execute("SET lc_time_names = 'es_ES'")
MsgStop( "ERROR AL INTENTAR ESTABLECER LA VARIABLE <SET lc_time_names>",'Error de conexión')
Application:Terminate()
Endif

END


MsgInfo( 'Base de Datos '+cDataBase+': Lista', 'Aviso' )

WITH OBJECT ::oPrueba
:oDataSource := ::oMaria
:cSelect := "select * from cliente"
:nCursorType := adOpenDynamic
:nLockType := adLockOptimistic
:cProcess := 'GENERAL'
IF :lOpen
:Close()
ENDIF
IF !:lOpen
:lOpen:= .T.
IF !:lOpen
MsgStop( "ERROR: No es posible abrir el archivo Cliente", "Error de conexion.." )
RETURN NIL
ENDIF
ENDIF
:lReadOnly := .F.
IF :RecCount() > 0
MsgInfo( 'Tengo Datos' )
ENDIF
END

Saludos
Responder