Sign in to follow this  
Followers 0
Nirvana6

AODDB help

5 posts in this topic

#1 ·  Posted (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 by Nirvana6

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

Did you set the variable $iPort to your port number?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, I did.


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