Jump to content
Sign in to follow this  
Jewtus

Connecting without setting up ODBC

Recommended Posts

Jewtus

I am trying to connect to a database but I use an ODBC connection on my machine that I'm trying to eliminate the dependence on (I'm using the IBM DB2 connector which is not free... I had a trial version).

This code works, but only if I have the ODBC connector setup in the windows settings:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.Mode = 16  ; shared
$sqlCon.CursorLocation = 3 ; client side cursor
$sqlCon.Open ("DSN="&$DSN&";UID="&$USERNAME&";Password="&$PASS&";DBALIAS="&$alias)
If @error Then
    MsgBox(0, "ERROR", "Failed to connect to the database")
    Exit
EndIf

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(0)  ; to check for after this function returns
Endfunc

But I want to connect without needing to install any software on the machine (so there is no localized configurations needed). Does anyone know of a way to get around this? Maybe with a DLL file that I can call directly and include with the script?

Edited by Jewtus

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  

  • Similar Content

    • Valnurat
      By Valnurat
      I hope my title is good enough.
      I'm using the ADO UDF and I have question regarding editing SQL records with this UDF.
      The owner of the UDF suggested an idea, but maybe there is another trix.
    • Bowmore
      By Bowmore
      A few months ago someone posted a function that scanned a PC registry and returned a list of all the available ADODB connections installed. I've been searching on and off all afternoon trying to locate it. Does anyone remember which topic this was in? As far as my failing memory goes it was a post part way through an ADO related topic.
      Thanks
       
    • mLipok
      By mLipok
      I want to present BETA Version of my ADO.au3 UDF.
      This is modifed version of _sql.au3 UDF.
       

      For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH
       
      This is first public release , and still is as BETA
       
       
      DOWNLOAD LINK (in download section): 
       

       
      Have fun,
      mLipok
       
       
      EDIT: 2016-06-03
      Below some interesting topics about databases:
       
       
      EDIT 2016/07/04:
      For more info about ADO look here:
      https://www.autoitscript.com/wiki/ADO
       
       
    • mLipok
      By mLipok
       
       
      Currently I'm working on MS SQL >> PostgreSQL migration.
      Here are some of interesting Video tutorials about PostgreSQL
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
    • mLipok
      By mLipok
      I want to present BETA Version of my ADO.au3 UDF.
      Support topic is here: http://www.autoitscript.com/forum/index.php?showtopic=180850
       
      This UDF is modifed version of _sql.au3 UDF.

      For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH
       
       
×