JeromeB Posted November 24, 2010 Share Posted November 24, 2010 (edited) Hello everyone, A part of my script consist to get information from a database in an SQL server 2003. If you can give me an example, i would like to get in variables information from the database "Sonde" in a servor "DS" (need to login in, so user / pass), and get back information from table "dbo.config". If someone can give me this part of code (connection + informations), and maybe some exemple to write in a table ( SQl commande insert into...) ? thx for helping, Jerome Edited November 24, 2010 by Jerome60 Link to comment Share on other sites More sharing options...
water Posted November 24, 2010 Share Posted November 24, 2010 There is a available that should do what you need. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JeromeB Posted November 24, 2010 Author Share Posted November 24, 2010 Yep, i saw this UDf, but can you give me an example with what i need to do ? mu informations ? Thx Link to comment Share on other sites More sharing options...
water Posted November 24, 2010 Share Posted November 24, 2010 (edited) Something like this: #include <_SQL.au3> #include <array.au3> Global $sServer = "DS" Global $sDB = "Sonde" Global $sUsername = "????", $sPassword = "????" Global $aResult, $iRows, $iColumns $oADODBHandle = SQL_Startup() $iReturn = _SQL_Connect($oADODBHandle, $sServer, $sDB, $sUsername, $sPassword) _SQL_GetTable2d($oADODBHandle, "select * from dbo.config", $aResult, $iRows, $iColumns) _ArrayDisplay($aResult) _$iResult = _SQL_Close() This is a very simple example and completely lags error handling. Check the returncode of each function and use function _SQL_RegisterErrorHandler to establish an error handler. Edited November 24, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JeromeB Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) Hey,thx for your reply, but its not working ...==> The requested action with this object has failed.: $ADODBHandle.Open("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") $ADODBHandle.Open("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";")^ ERRORDon't know why, i put the good password and user "sa".I think its the DRIVER the problem, but how can i know which driver do i have to put ? Refer to i got the same error code, so its the driver, but what i have to do to fix it ? Edited November 24, 2010 by Jerome60 Link to comment Share on other sites More sharing options...
water Posted November 24, 2010 Share Posted November 24, 2010 (edited) $sServer = "DS" seems to be a bit short. Is this the name of the physical machine your SQL server is hosted? Can you ping this server? Is the Microsoft SQL driver installed on your machine? Open the command prompt and run "odbccp32.cpl" and check if a driver named "SQL Server" is available. Edited November 24, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JeromeB Posted November 24, 2010 Author Share Posted November 24, 2010 (edited) Server is not DS, but its ok, i didnt want to give you the name of my server, but i changed it in my script, no worry. SQL server driver is installed on my computer, this is ok too. And i can ping my server xD In my SQL server, i can read : SQL Server 9.0.4035 Edited November 24, 2010 by Jerome60 Link to comment Share on other sites More sharing options...
water Posted November 26, 2010 Share Posted November 26, 2010 Could you please insert the following line _SQL_RegisterErrorHandler()into your script before line: $oADODBHandle = SQL_Startup() The error handler should write some useful information to the console. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted November 26, 2010 Share Posted November 26, 2010 Search forum for ObjCreate("ADODB.Connection") ObjCreate("ADODB.Recordset") There are many examples also with DSN string examples ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Elias Posted December 16, 2010 Share Posted December 16, 2010 (edited) Thanks for the SQL UDF here gos my contribution for the SQL_UDF.au3Getting TABLE NAME From the Data BASE New Function _SQL_GetTableName() for SQLMoved to: Edited December 18, 2010 by Elias Link to comment Share on other sites More sharing options...
Elias Posted December 17, 2010 Share Posted December 17, 2010 (edited) SQL GUI using "_sql.au3"Moved to: Edited December 18, 2010 by Elias Link to comment Share on other sites More sharing options...
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