Sign in to follow this  
Followers 0
THERUNZ

SQL Connection Error

5 posts in this topic

#1 ·  Posted (edited)

Hello all,

I am having problem connecting to my SQL database and have hit a snag as was wondering if anyone could help me out. Here is the code I've got:

$conn = ObjCreate( "ADODB.Connection" )

$DSN = "Driver={SQL SERVER};SERVER=**server**;PORT=**port**;UID=**username**;PWD=**password**;"

$conn.Open($DSN)

The error I keep getting is:

We intercepted a COM Error!

Number is: 80020009

Description is: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.

I have tried changing the actual server name to IP address, I've tried adding Trusted_Connection=no to the script but same error every time. When adding the connection through SQL Developer 3.1 it adds the connection just fine with all of the same information specified above. I can ping the server just fine.

I have also tried a different driver using “Microsoft ODBC for Oracle” but receive the error:

We intercepted a COM Error!

Number is: 80020009

Description is: [Microsoft][ODBC Driver Manager]Driver’s SQLSetConnectAttr failed

Can anyone provide me with insight on what else I can try to get this connection working right?

Any help would be much appreciated :)

Edited by THERUNZ

Share this post


Link to post
Share on other sites



I am able to login to the server manually and im able to telnet into it. Could there be something in my code that I'm missing?

Share this post


Link to post
Share on other sites

I am pretty sure there is something wrong with your connection string. It simply doesn't look like ones I have seen in the past. You might want to Google various examples of how they are implemented through vbs script, as the string should be the same for you.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You missed "Database=" in your DSN

I use this DSN in my project for MSSQL server, I replace %variable% to real values before connection.

$DSN = "Driver={SQL Server};Server=%server%;Database=%database%;Uid=%name%;Pwd=%password%;"

You may try to use database master if you don't want some particular one.

EDIT:

If you use 64bit OS then try to use

#AutoIt3Wrapper_UseX64=n

Edited by Zedna

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