Nirvana6 Posted February 16, 2012 Posted February 16, 2012 (edited) So, basically , I am trying to read a database from a server (eventually write something in it) I looked around and I found this piece of code : ; Specify an ini file to write to $sIni = @ScriptDir & "Documents.ini" ; Connect to the database $conn = ObjCreate( "ADODB.Connection" ) $DSN = "DRIVER={SQL Server};SERVER=********;DATABASE=********;UID=*****;PWD=*******;" $conn.Open($DSN) ;Create record set and run query $rs = ObjCreate("ADODB.RecordSet") $rs.Open("select * from public.extorders where id > 0", $conn) If $RS.RecordCount Then While Not $RS.EOF Consolewrite("cnum: " & $rs.Fields("cust_num").value & @CRLF) $RS.MoveNext WEnd EndIf $RS.Close $conn.close After I run the script I get this error ############################### err.description is: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. err.windescription: Unspecified error err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 220 err.source is: Microsoft OLE DB Provider for ODBC Drivers err.helpfile is: err.helpcontext is: 0############################### ############################### err.description is: Operation is not allowed when the object is closed. err.windescription: err.number is: 80020009 err.lastdllerror is: 0 err.scriptline is: 373 err.source is: ADODB.Connection err.helpfile is: C:windowsHELPADO270.CHM err.helpcontext is: 1240653############################### notes : -server does exist. -correct username/pass -i also have a port number , but i am not sure if it's necessary or where I can insert it. Thoughts ? Thanks in advance. Edited February 16, 2012 by Nirvana6
water Posted February 16, 2012 Posted February 16, 2012 You can append the port to $DSN: "...;PORT="&$iPort Default for SQL Server is port 1433. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Nirvana6 Posted February 16, 2012 Author Posted February 16, 2012 ok , when I add the port it generates this : C:Users***DesktopNew AutoIt v3 Script (3).au3 (11) : ==> The requested action with this object has failed.: $conn.Open($DSN) $conn.Open($DSN)^ ERROR Do I need to have any other software installed ? $DSN = "DRIVER={SQL Server};SERVER=*****;DATABASE=****;UID=*****;PWD=*****;PORT="&$iPort $conn.Open($DSN)
water Posted February 16, 2012 Posted February 16, 2012 Did you set the variable $iPort to your port number? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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