Sign in to follow this  
Followers 0
nevodj

Query FIREBIRD 2.0 Database

8 posts in this topic

Hello,

I can't find anything helpful in the forums about querying a Firebird database.

Does anyone know if this can be done and how?

Thanks

Share this post


Link to post
Share on other sites



Hi nevodj, see

#include <FireBird.au3>
Local $wer
Global $h_fbDll = DllOpen("C:\bird\bin" & "\fbdll4vb20.dll")
Global $servername="192.168.0.5"
Global $sDBName="C:\Program Files\Firebird\Firebird_1_5\bin\Zimkps.gdb"
Local $sUsername = "sysdba"
Local $sPassword = "masterkey"
;_FireBird_Help($h_fbDll)
_FireBird_ConnectDatabase($h_fbDll, $servername, $sDBName, $sUsername, $sPassword)
;_FireBird_About($h_fbDll)
;_FireBird_Help($h_fbDll)
ConsoleWrite( _FireBird_ExecuteStatement($h_fbDll,"select * from tubaina"))
exit

Visit my repository

Share this post


Link to post
Share on other sites

Thanks detefon

I dont really understand dll calls or firebird.. i'm an SQL fan and have never touched one of our systems which is running on firebird... i have the firebird database on a windows server, does this script require firebird to be installed on the client machine before the script will connect?

the filepaths to the dll and the .gdb, are they were the files are located on the server or the client?

Global $h_fbDll = DllOpen("C:\bird\bin" & "\fbdll4vb20.dll")

Global $servername="192.168.0.5"

Global $sDBName="C:\Program Files\Firebird\Firebird_1_5\bin\Zimkps.gdb"

thanks for your help

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi nevodj, now with more information! 8D

Good luck!

#include <FireBird.au3>
Global $h_fbDll = DllOpen("C:\bird\bin\fbdll4vb20.dll")   ; path from 'fbdll4vb20.dll' in client side.
Global $servername = "192.168.0.5"      ; Firebird IP server
 
Global $sDBName="C:\Program Files\Firebird\Firebird_1_5\bin\Zimkps.gdb"
; The line above is the path from 'Zimkps.gdb' in the server
; You must write a script client with a path server from .gdb file
Local $sUsername = "sysdba"
Local $sPassword = "masterkey"
_FireBird_ConnectDatabase($h_fbDll, $servername, $sDBName, $sUsername, $sPassword)
ConsoleWrite( _FireBird_ExecuteStatement($h_fbDll, "select * from tubaina"))
Edited by detefon

Visit my repository

Share this post


Link to post
Share on other sites

thanks champ, couple of things i still dont understand:

1.

Global $h_fbDll = DllOpen("C:\bird\bin\fbdll4vb20.dll") ; path from 'fbdll4vb20.dll' in client side.

does this mean firebird has to be installed on the client?

2.

; You must write a script client with a path server from .gdb file

... could you explain here?

thanks!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

[Client side]

Global $h_fbDll = DllOpen("C:\bird\bin\fbdll4vb20.dll") ; path from 'fbdll4vb20.dll' in client side.

The AutoIt do not have parts to connnect in firebird, you must have download this dll (fbdll4vb20.dll) and put in someplace, maybe in the same folder like your client's script or another folder... This is only the path's dll.

I make the test with script a long time ago... I cant' remenber now if is necessary install firebird client or only download fbdll4vb20.dll and use that.

I know a little of MySQL, and it need only to connect: IP, username, password... Nothing more.

[server side]

Firebird needed: IP, username, password and the path's DB (or $sDBName).

This path is a place's from .gdb file in the server machine.

After you install a firebird module server in your 'server' and create your database's firebird, you must find the folder's .gdb file.

Something like this...

Global $sDBName="C:\Program Files\Firebird\Firebird_1_5\bin\Zimkps.gdb"

Good Luck (II)!

Edited by detefon

Visit my repository

Share this post


Link to post
Share on other sites

ok i've got this far. when i run it i get this message -

IBPP::Exception inside GDS::Call()***

IBPP Message : Can't find/load FBCLIENT.DLL nor GDS32.DLL

Share this post


Link to post
Share on other sites

hi guy i try to connect whit dll at the db fire bird but autoit tell me

C:\Program Files (x86)\AutoIt3\Include\FireBird.au3 (195) : ==> Subscript used with non-Array variable.:

Return SetError($vRet[0] <> 0, 0, $vRet[0])

Return SetError($vRet^ ERROR

why ?? ;)(((

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • sc4ry
      By sc4ry
      Dear all,
      I already have a formula which will select doublicates, but sometimes there might be entries with additional information starting after "-", which I now want to trim away.
      Current formula is:
      Select DISTINCT a.title, a.oid, a.size, a.disk from DB a, DB b where (a.title like b.title and a.oid <> b.oid)" & $ActiveDisks_Filter & " AND (a.comment <> 'Delete' AND b.comment <> 'Delete') Order by a.title ASC, a.size DESC; testwise I want to add a simple solution like left, but afterwards I get an error but I do not know why.
      Select DISTINCT a.title, a.oid, a.size, a.disk from DB a, DB b where (left(a.title,15) like b.title and a.oid <> b.oid) Order by a.title ASC, a.size DESC; Error: near "(": syntax error: Finally I would like to insert intstr to search for "-" but currently I am not able to extend my current code =/
      Thanks a lot for your help.
      EDIT: hey, I managed it, left was not working also it was somehow shown that the tool knowed the comment. I did it now with substr+instr
      (substr(a.title, 1, instr(a.title, ' - '))  
    • AndyS19
      By AndyS19
      I have code that does a WMI SQL query to find all defined printers, and I want to parse the returned object in several places.  However, after parsing it the first time, all other times fail to find any printer objects.
      Here is my test code:
      test() Func test() Local $oPrinters, $oPrinter, $err, $cnt, $oP, $query $query = "SELECT * FROM Win32_Printer" $oPrinters = doQuery($query) $err = @error LogMsg("+++: $err = " & $err & ", isObj($oPrinters) = " & IsObj($oPrinters)) If ($err == 0) Then LogMsg("FIRST LOOP") ; <=== FIRST LOOP $cnt = 0 $oP = $oPrinters LogMsg("+++: isObj($oP) = " & IsObj($oP)) For $oPrinter In $oP $cnt += 1 LogMsg("+++: isObj($oPrinter): " & IsObj($oPrinter) & ", $oPrinter.Name ==>" & $oPrinter.Name & "<==") Next LogMsg("+++: Found " & $cnt & " printers") LogMsg("SECOND LOOP") ; <== SECOND LOOP $cnt = 0 $oP = $oPrinters LogMsg("+++: isObj($oP) = " & IsObj($oP)) For $oPrinter In $oP $cnt += 1 LogMsg("+++: isObj($oPrinter): " & IsObj($oPrinter) & ", $oPrinter.Name ==>" & $oPrinter.Name & "<==") Next LogMsg("+++: Found " & $cnt & " printers") EndIf EndFunc ;==>test Func doQuery($sQuery, $lnum = @ScriptLineNumber) #forceref $lnum LogMsg("+++:" & $lnum & ": doQuery(" & '"' & $sQuery & '"' & ") entered") Local $oWMIService, $oResults, $errstr Local $wbemFlags = BitOR(0x20, 0x10) ; $wbemFlagReturnImmediately and wbemFlagForwardOnly $oWMIService = ObjGet("winmgmts:\\" & "localhost" & "\root\CIMV2") If (IsObj($oWMIService)) Then $oResults = $oWMIService.ExecQuery($sQuery, "WQL", $wbemFlags) If (IsObj($oResults)) Then LogMsg("+++: doQuery() returns @error = 0, Good: returning the object") Return (SetError(0, 0, $oResults)) ;;; Good: return the object Else $errstr = "" _ & "WMI Query failed." & @CRLF _ & "This is the query:" & @CRLF _ & " " & $sQuery LogMsg("+++: ====>" & $errstr & "<===") LogMsg("+++: doQuery() returns @error = 1") Return (SetError(1, 0, $errstr)) ; Error: Query faled EndIf Else $errstr = "" _ & "WMI Output" & @CRLF _ & "No WMI Objects Found for class: " & @CRLF _ & "Win32_PrinterDriver" & @CRLF _ & "using this query:" & @CRLF _ & " " & $sQuery LogMsg("+++: ====>" & $errstr & "<===") MsgBox(0, "ERROR", $errstr) ; Error: Cannot get $oWMIService object Exit (1) EndIf EndFunc ;==>doQuery Func LogMsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>LogMsg Parsing the returned $oPrinters object shows 5 printers:
      +++:15: FIRST LOOP +++:18: +++: isObj($oP) = 1 +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Microsoft XPS Document Writer<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Microsoft Office Document Image Writer<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Fax<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Canon MG7100 series Printer WS<== +++:22: +++: isObj($oPrinter): 1, $oPrinter.Name ==>Canon MG6100 series Printer WS<== +++:24: +++: Found 5 printers Parsing it again, shows no printers:
      +++:26: SECOND LOOP +++:29: +++: isObj($oP) = 1 +++:35: +++: Found 0 printers  
    • GhostLine
      By GhostLine
      Hello guys !
      I'm stuck in something stupid (I guess), but since I've no clue on how to solve it, here I come
      I'm trying to collect the result of the query "select @@hostname" on MSSQL Server, but it doesn't work ... and I'm sure I'm connected to the database (I've successfully seen the database treeview). 

      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include<_sql.au3> #include<array.au3> Local $aData,$iRows,$iColumns ;Server ID and credentials for tCards Global $ServerAddressT = "10.200.88.1" Global $ServerUserNameT = "user" Global $ServerPasswordT = "password" Global $DatabaseNameT = "DataBASE" ;Connect to DB _SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error $OADODB = _SQL_Startup() If $OADODB = $SQL_ERROR Then MsgBox(0 + 16 + 262144, "Error", _SQL_GetErrMsg()) If _sql_Connect(-1, $ServerAddressT, $DatabaseNameT, $ServerUserNameT, $ServerPasswordT) = $SQL_ERROR Then     MsgBox(0 + 16 + 262144, "Error 1", _SQL_GetErrMsg())     _SQL_Close()     Exit Else     If _SQL_Execute(-1,"select @@SERVERNAME") = $SQL_ERROR then         Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())     Else         _ArrayDisplay(_SQL_GetTable(-1,"select @@SERVERNAME",$aData,$iRows,$iColumns)) ;~         $toto = _SQL_Execute(-1,"select @@SERVERNAME") ;~         _ArrayDisplay($toto)     EndIf EndIf
    • Gorby7
      By Gorby7
      I have an Autoit-based client GUI that uses a single MS SQL Server database. I have no problem connecting to and executing queries against this database from my AutoIT code, with the below exception:
      One of the database's stored procedures I need to execute requires a parameter that is a table. I've set up the appropriate table_type on the database and everything works fine on the database itself when I execute the stored proc with a table variable for the parameter (no AutoIT involved). The problem is that I can't figure out how to pass a table parameter from AutoIT, assuming it's even possible. The code below shows the two methods I've tried, both methods return a RecordSet object that is at EOF.
      #include <Array.au3> Opt("MustDeclareVars", 0) $sDBSrv = "ITSQL01.domain.com" $sDBName = "INVDEV" $sADOName = "ADODB.Connection" $oSQLConn = ObjCreate($sADOName) $sConnStr = "Driver={SQL Server};Server=" & $sDBSrv & ";Database=" & $sDBName & ";Trusted_Connection=yes;" $oSQLConn.Open ($sConnStr) $rsoFacFriendly = $oSQLConn.Execute("SELECT TOP 5 FriendlyName FROM Facility") If Not $rsoFacFriendly.EOF Then $aFacFriendly = $rsoFacFriendly.GetRows() _ArrayDisplay($aFacFriendly) $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $aFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec1", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec1", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec1", "At end of file") Case Else MsgBox(0, "sp exec1", "Something else happened") EndSelect $rsoSPResults = 0 $rsoSPResults = $oSQLConn.Execute("EXEC spTableParameterPassTest " & $rsoFacFriendly) Select Case $rsoSPResults.EOF = False MsgBox(0, "sp exec2", "not end of file") $aSPResults = $rsoSPResults.GetRows() _ArrayDisplay($aSPResults) Case IsObj($rsoSPResults) = 0 MsgBox(0, "sp exec2", "rso isn't even an object") Case $rsoSPResults.EOF = True MsgBox(0, "sp exec2", "At end of file") Case Else MsgBox(0, "sp exec2", "Something else happened") EndSelect $rsoSPResults = 0 $rsoFacFriendly = 0 $oSQLConn.Close $oSQLConn = 0 Exit  
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning guys
      I'd like to know if there is a way to convert a PDF in CSV or, eventually, in TXT, in order to read from it, like a database...
      I have a PDF and I think ( I dind't search a lot on the forum ) with AutoIt, but I'd like work with Excel styles...
      Does anyone know a good program which convert PDF to CSV? 
      PS: the PDF file is 5 MB, and it contains 439 pages...
      Thanks everyone for the help