Jango Posted February 11, 2008 Posted February 11, 2008 Hello, I don't know if it's possible but i'm looking for a way to create ODBC connection with AutoIt. I can find something relevant ... if someone have information about that please help
BrettF Posted February 11, 2008 Posted February 11, 2008 Hello,I don't know if it's possible but i'm looking for a way to create ODBC connection with AutoIt.I can find something relevant ... if someone have information about that please helpHave you done a forum search of ODBC? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Jango Posted February 11, 2008 Author Posted February 11, 2008 Have you done a forum search of ODBC?Yes but to be clear i'm looking for a way to automate the creation of an ODBC connection not to use ODBC connection in my script ... i don't know if i'm clear as english is not my native language.
ptrex Posted February 11, 2008 Posted February 11, 2008 @Jango Why do you need an ODBC setup at the client ? Much better is to use the DNS less connections. Works without a ODBC setup. Which DB are you trying to connect to ? regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Jango Posted February 11, 2008 Author Posted February 11, 2008 (edited) @JangoWhy do you need an ODBC setup at the client ?Much better is to use the DNS less connections. Works without a ODBC setup.Which DB are you trying to connect to ?regardsptrex@ptrexIn fact i made a script to install SQL Server Package (on the server) and execute it, these package use ODBC connection to connect to another DB (IBM AS400 DB) and actually i log on the server and create the ODBC connection manually (Settings/Control Panel/Administrative Tools/ODBC) but i would like to automate this process as i have many server to installEdit: it's Microsoft SQL Server 2005 Edited February 11, 2008 by Jango
ptrex Posted February 11, 2008 Posted February 11, 2008 @Joango This should get you connected to an DB2 / AS 400 without an ODBC. expandcollapse popup; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Mode = 16 ; shared $sqlCon.CursorLocation = 3 ; client side cursor $sqlCon.Open ("Driver={DB2}; IP=[ip_address]; Port=[port_number]; Database=[database_name]; UID=[username]; PWD=[password]") If @error Then MsgBox(0, "ERROR", "Failed to connect to the database") Exit EndIf ; See also Catalog "ADOX Catalog Example.au3" $sqlRs = ObjCreate("ADODB.Recordset") If Not @error Then $sqlRs.open ("select * from Table", $sqlCon) If Not @error Then ;Loop until the end of file While Not $sqlRs.EOF ;Retrieve data from the following fields $OptionName = $sqlRs.Fields ('name' ).Value $OptionVal = $sqlRs.Fields ('value' ).Value MsgBox(0, "Record Found", "Name: " & $OptionName & @CRLF & "Value: " & $OptionVal) $sqlRs.FIELDS('"' & $OptionName & '"') = ".F." ; ADDED THIS LINE ; $sqlRs.Update ; ADDED THIS LINE $sqlRs.MoveNext WEnd $sqlRs.close EndIf 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(1) ; to check for after this function returns Endfunc Not tested it because I don't have an AS400 around. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
ptrex Posted February 11, 2008 Posted February 11, 2008 @Jango This one is for MS SQL. ; Only for SQL server $objConn = ObjCreate("ADODB.Connection") $objConn.Open("Provider='sqloledb';Data Source='mysqlserver';Initial Catalog='Northwind';User ID='sa';Password='password';") $rsCustomers = $objConn.Execute("SELECT * FROM Customers") With $rsCustomers While Not .EOF ConsoleWrite(.Fields("CustomerID").Value & " - " & .Fields("CompanyName").Value & @LF) .MoveNext WEnd .Close EndWith $objConn.Close Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Jango Posted February 11, 2008 Author Posted February 11, 2008 thank you for these script ptrex, i saved it But i can't change the way SQL package access the DB and it need an ODBC connection setup so i think i need to poke in the registry to do that...
ptrex Posted February 11, 2008 Posted February 11, 2008 @Jango,Don't worry, here's one in VBScript that can easily be translated in AU3.ODBC DSNregardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Jango Posted February 11, 2008 Author Posted February 11, 2008 @Jango,Don't worry, here's one in VBScript that can easily be translated in AU3.ODBC DSNregardsptrexGreat this is i was looking for !
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now