Jump to content

SQL connection fails


bourny
 Share

Recommended Posts

I am attampting to talk to my Sophos SQL DB using AutoIT. I am using a working script that connects to a different servers SQL db to do other queries but my sophos server refuses the connection - Below is my script

#include <_sql.au3>

$con = _SQLStartup()

If @error then Msgbox(0,"Error","Error starting ADODB.Connection")

_SQLConnect(-1,"MYSOPHOSSERVER","SOPHOSDB","USERNAME","PASSWORD")

if @Error then Msgbox(0,"",$SQLErr)

I get the following colsole output

_sql.au3 (49) : ==> The requested action with this object has failed.:

$ConHandle.Open ("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";")

$ConHandle.Open ("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";")^ ERROR

The username and password are DBO on the database required - I am guessing I may need some sort of ODBC data connection set up but not sure how the _sql include file works...

The code in the SQL file that handles the connection is

Func _SQLConnect($ConHandle,$server, $db, $username, $password)

DIM $SQLErr

If $ConHandle = -1 then $ConHandle = $sqlLastConnection

$ConHandle.Open ("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials

If NOT @error then return 1

Return SetError(1,0,0)

EndFunc

Thanks

Link to comment
Share on other sites

I am attampting to talk to my Sophos SQL DB using AutoIT. I am using a working script that connects to a different servers SQL db to do other queries but my sophos server refuses the connection - Below is my script

The username and password are DBO on the database required - I am guessing I may need some sort of ODBC data connection set up but not sure how the _sql include file works...

The code in the SQL file that handles the connection is

Func _SQLConnect($ConHandle,$server, $db, $username, $password)

DIM $SQLErr

If $ConHandle = -1 then $ConHandle = $sqlLastConnection

$ConHandle.Open ("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials

If NOT @error then return 1

Return SetError(1,0,0)

EndFunc

Thanks

Is the parameter "DRIVER={SQL Server}" correct? What I mean is, when you said "my Sophos SQL DB", did you mean your Sophos DB held on a Microsoft SQL Server?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Is the parameter "DRIVER={SQL Server}" correct? What I mean is, when you said "my Sophos SQL DB", did you mean your Sophos DB held on a Microsoft SQL Server?

:)

It Appears my server I am connecting to does not like me putting a username and password on the connection - Seems the DB needs locked down a bit more as it is as open as my windows on a hot summer day. It now works if I ommit the username and password and just leave in the server and database name

Thanks

Link to comment
Share on other sites

It Appears my server I am connecting to does not like me putting a username and password on the connection - Seems the DB needs locked down a bit more as it is as open as my windows on a hot summer day. It now works if I ommit the username and password and just leave in the server and database name

Thanks

Eek... :)

Well, it's good you found that out so it can get secured!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...