Sign in to follow this  
Followers 0
bandersen

SQL connection

2 posts in this topic

Hi

I have made a simpel database with Visual Web Developer. I have also added a SQL server connection in the ODBC Data Source Administrator, that points to the database. There is no login to the database, I am using the "Use Windows Authentication", to connect to the database.

I have then made the following AutoIT test script just to connect to the databse:

$oConn = ObjCreate("ADODB.Connection")

$sqlCon.Open("DRIVER={SQL Server};SERVER=DK-263\SQLEXPRESS;DATABASE=RIS_SERVER_DATA;")

if @error Then

MsgBox(0, "ERROR", "Failed to connect to the database")

Exit

Else

MsgBox(0, "Success!", "Connection to database successful!")

EndIf

Then I get the following error:

Posted Image

What is wrong with the connection?

BR

Benjamin Andersen

Share this post


Link to post
Share on other sites



Hi

Yes finally made it work :)

With the following code:

$conn = ObjCreate( "ADODB.Connection" )

$DSN = "DRIVER={SQL Server};SERVER=DK-263\SQLEXPRESS;DATABASE=RIS_SERVER_DATA;UID=;PWD=;"

$conn.Open($DSN)

$rs = ObjCreate( "ADODB.RecordSet" )

$rs.Open( "SELECT @@VERSION AS myVersion", $conn )

MsgBox(0, "AutoIT-SQL Result", "Value = " & $rs.Fields( "myVersion" ).Value )

$conn.close

BR

Benjamin Andersen

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