Post by kintar0e » 25 Aug 2022, 13:39
Aqui un ejemplo usando adosql (probado en windows7 64bits, firebird 2.5.9 x64)
Si es en la misma PC donde esta instalado Firebird usando: connection string Local database Firebird.
Si es desde otra pc en LAN puedes usar connection string Remote connection to Firebird.
he adjuntado el archivo adosql que use para que lo descargues. Tu script que creas tiene que estar en la misma carpeta que el adosql.ahk
Code: Select all
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
; https://www.autohotkey.com/board/topic/83542-func-adosql-uses-ado-to-manage-sql-transactions-v503l/
#Include, adosql.ahk
DB_UserName := "manager" ; Change this accordingly. Use the same username you use to connect to.
DB_Password := "admin" ; Change this accordingly.
Data_Source := "192.168.100.111" ; Change this accordingly. The intranet IP of the server should do depending on how the server is configured in the network.
DB_Initial_Catalog := "C:\FirebirdDB\CHECADOR.fdb" ; Change this accordingly.
; https://www.connectionstrings.com/firebird/
;--------------------------------------- Local database Firebird
ConnStr := "DRIVER=Firebird/InterBase(r) driver;UID=" DB_UserName ";PWD=" DB_Password ";DBNAME=" DB_Initial_Catalog ";"
;-------------------------------------- Remote connection to Firebird
; ConnStr := "DRIVER=Firebird/InterBase(r) driver;UID=" DB_UserName ";PWD=" DB_Password ";DBNAME=" Data_Source ":" DB_Initial_Catalog ";"
; -------------------------------GUI
Gui Add, Text, x16 y8 w19 h23 +0x200, ID
Gui Add, Edit, vid_ebox x40 y8 w47 h24 +Number
Gui Add, Text, x104 y8 w36 h23 +0x200, Fecha
Gui Add, DateTime, vfecha_dtp x144 y8 w100 h24
Gui Add, Button, gBuscarIDFecha x248 y8 w62 h25 +Default, Buscar
Gui Add, Text, x16 y48 w287 h2 +0x10
Gui Add, Text, x16 y56 w99 h23 +0x200, Empleado
Gui Font, s10 c0xFF0080
Gui Add, Edit,vNombre_ebox x16 y80 w182 h25 +ReadOnly,Nombre de Empleado
Gui Font
Gui Add, Text, x208 y56 w99 h23 +0x200, Resultado HORA:
Gui Font, s16 c0xFF0080
Gui Add, Edit,vHora_ebox x208 y80 w105 h26 +ReadOnly,
Gui Font
Gui Add, StatusBar,,
Gui Show, w325 h145, Hora Empleado
Return
BuscarIDFecha:
Gui, Submit, NoHide
if !id_ebox
{
MsgBox, 64, id vacio, El campo id esta vacio,2
Return
}
if !fecha_dtp
{
MsgBox, 64, , Falta selecionar fecha,2
Return
}
FormatTime, fecha, % fecha_dtp, yyyy-MM-dd
; Select a.Horaing from Empleados as a Where a.ID = (TEXTBOX1 de Autohotkey) and a.Date = (TEXTBOX2 de Autohotkey)
Query := "SELECT a.NOMBRE,a.HORAING FROM EMPLEADOS a WHERE a.ID = '" id_ebox "' AND a.FECHA = '" fecha "'"
ObjectReturn := ADOSQL(ConnStr, Query)
if IsObject(ObjectReturn){
if (ObjectReturn.MaxIndex() > 1)
{
GuiControl,,Nombre_ebox, % ObjectReturn[2,1]
GuiControl,,Hora_ebox, % ObjectReturn[2,2]
} else {
MsgBox, 64, , No hay resultados,2
GuiControl,,Nombre_ebox,
GuiControl,,Hora_ebox,
}
} else {
Msgbox, No es objeto
}
Return
GuiEscape:
GuiClose:
ExitApp
- Attachments
-
- adosql.ahk
- (6.07 KiB) Downloaded 29 times
Aqui un ejemplo usando adosql (probado en windows7 64bits, firebird 2.5.9 x64)
Si es en la misma PC donde esta instalado Firebird usando: connection string Local database Firebird.
Si es desde otra pc en LAN puedes usar connection string Remote connection to Firebird.
he adjuntado el archivo adosql que use para que lo descargues. Tu script que creas tiene que estar en la misma carpeta que el adosql.ahk
[code]
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
; https://www.autohotkey.com/board/topic/83542-func-adosql-uses-ado-to-manage-sql-transactions-v503l/
#Include, adosql.ahk
DB_UserName := "manager" ; Change this accordingly. Use the same username you use to connect to.
DB_Password := "admin" ; Change this accordingly.
Data_Source := "192.168.100.111" ; Change this accordingly. The intranet IP of the server should do depending on how the server is configured in the network.
DB_Initial_Catalog := "C:\FirebirdDB\CHECADOR.fdb" ; Change this accordingly.
; https://www.connectionstrings.com/firebird/
;--------------------------------------- Local database Firebird
ConnStr := "DRIVER=Firebird/InterBase(r) driver;UID=" DB_UserName ";PWD=" DB_Password ";DBNAME=" DB_Initial_Catalog ";"
;-------------------------------------- Remote connection to Firebird
; ConnStr := "DRIVER=Firebird/InterBase(r) driver;UID=" DB_UserName ";PWD=" DB_Password ";DBNAME=" Data_Source ":" DB_Initial_Catalog ";"
; -------------------------------GUI
Gui Add, Text, x16 y8 w19 h23 +0x200, ID
Gui Add, Edit, vid_ebox x40 y8 w47 h24 +Number
Gui Add, Text, x104 y8 w36 h23 +0x200, Fecha
Gui Add, DateTime, vfecha_dtp x144 y8 w100 h24
Gui Add, Button, gBuscarIDFecha x248 y8 w62 h25 +Default, Buscar
Gui Add, Text, x16 y48 w287 h2 +0x10
Gui Add, Text, x16 y56 w99 h23 +0x200, Empleado
Gui Font, s10 c0xFF0080
Gui Add, Edit,vNombre_ebox x16 y80 w182 h25 +ReadOnly,Nombre de Empleado
Gui Font
Gui Add, Text, x208 y56 w99 h23 +0x200, Resultado HORA:
Gui Font, s16 c0xFF0080
Gui Add, Edit,vHora_ebox x208 y80 w105 h26 +ReadOnly,
Gui Font
Gui Add, StatusBar,,
Gui Show, w325 h145, Hora Empleado
Return
BuscarIDFecha:
Gui, Submit, NoHide
if !id_ebox
{
MsgBox, 64, id vacio, El campo id esta vacio,2
Return
}
if !fecha_dtp
{
MsgBox, 64, , Falta selecionar fecha,2
Return
}
FormatTime, fecha, % fecha_dtp, yyyy-MM-dd
; Select a.Horaing from Empleados as a Where a.ID = (TEXTBOX1 de Autohotkey) and a.Date = (TEXTBOX2 de Autohotkey)
Query := "SELECT a.NOMBRE,a.HORAING FROM EMPLEADOS a WHERE a.ID = '" id_ebox "' AND a.FECHA = '" fecha "'"
ObjectReturn := ADOSQL(ConnStr, Query)
if IsObject(ObjectReturn){
if (ObjectReturn.MaxIndex() > 1)
{
GuiControl,,Nombre_ebox, % ObjectReturn[2,1]
GuiControl,,Hora_ebox, % ObjectReturn[2,2]
} else {
MsgBox, 64, , No hay resultados,2
GuiControl,,Nombre_ebox,
GuiControl,,Hora_ebox,
}
} else {
Msgbox, No es objeto
}
Return
GuiEscape:
GuiClose:
ExitApp
[/code]