Jump to content

SQL help


Recommended Posts

I am using this script and I got following error:

G:\Documents and Settings\Tilen\Desktop\SQLTest.au3 (38) : ==> The requested action with this object has failed.:

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

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

>Exit code: 1 Time: 52.364

When I execute it waits around 20 sec then I get this...

Script:

$ala = "INSERT INTO izdelki VALUES ('Monitor2',350,15)"

$lol = _SQL_Startup()
_SQL_Connect($lol, "sql207.byethost14.com", "b14_xxxxxx_xxxx", "b14_xxxxxx", "xxxxxxx")
_SQL_Execute(-1, $ala)
_SQL_Close()


Exit





Func _SQL_Startup()
    
    $SQLErr = ""
    Local $adCN = ObjCreate("ADODB.Connection")
    If IsObj($adCN) Then
        $SQL_LastConnection = $adCN
        Return SetError("SQL_OK", 0, $adCN)
    Else
        $SQLErr = "Failed to Create ADODB.Connection object"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf
    
EndFunc
Func _SQL_Connect($ADODBHandle, $server, $db, $username, $password)
    
    $SQLErr = ""
    If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection
    
    If Not IsObj($ADODBHandle) Then
        $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf
    
    $ADODBHandle.Open("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials
    
    If Not @error Then
        Return SetError($SQL_OK, 0, $SQL_OK)
    Else
        $SQLErr = "Connection Error"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf
EndFunc
Func _SQL_Execute($hConHandle = -1, $vQuery = "")
    
    $SQLErr = ""
    Local $hQuery
    
    If $hConHandle = -1 Then $hConHandle = $SQL_LastConnection
    $hQuery = $hConHandle.Execute($vQuery)

    If @error Then
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    Else
        Return SetError($SQL_OK, 0, $hQuery)
    EndIf
EndFunc
Func _SQL_Close($ADODBHandle = -1)
    
    $SQLErr = ""
    
    If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection
    
    If Not IsObj($ADODBHandle) Then
        $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf
    
    $ADODBHandle.Close
    If $ADODBHandle = $SQL_LastConnection Then $SQL_LastConnection = ""
    
    Return SetError($SQL_OK, 0, $SQL_OK)

EndFunc

Here are information about server:

MySQL

* Server: sql207.byethost14.com via TCP/IP

* Server version: 5.0.81-1

* Protocol version: 10

* User: b14_xxxxxx@209.190.85.47

* MySQL charset: UTF-8 Unicode (utf8)

Web server

* Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny2 with Suhosin-Patch

* MySQL client version: 5.0.51a

* PHP extension: mysqli

Maybe is this because is MySQL and not SQL ?? or what is wrong :/

Edited by DoctorSLO
Link to comment
Share on other sites

I am using this script and I got following error:

G:\Documents and Settings\Tilen\Desktop\SQLTest.au3 (38) : ==> The requested action with this object has failed.:

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

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

>Exit code: 1 Time: 52.364

When I execute it waits around 20 sec then I get this...

Script:

CODE
$ala = "INSERT INTO izdelki VALUES ('Monitor2',350,15)"

$lol = _SQL_Startup()

_SQL_Connect($lol, "sql207.byethost14.com", "b14_xxxxxx_xxxx", "b14_xxxxxx", "xxxxxxx")

_SQL_Execute(-1, $ala)

_SQL_Close()

Exit

Func _SQL_Startup()

$SQLErr = ""

Local $adCN = ObjCreate("ADODB.Connection")

If IsObj($adCN) Then

$SQL_LastConnection = $adCN

Return SetError("SQL_OK", 0, $adCN)

Else

$SQLErr = "Failed to Create ADODB.Connection object"

Return SetError($SQL_ERROR, 0, $SQL_ERROR)

EndIf

EndFunc

Func _SQL_Connect($ADODBHandle, $server, $db, $username, $password)

$SQLErr = ""

If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection

If Not IsObj($ADODBHandle) Then

$SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"

Return SetError($SQL_ERROR, 0, $SQL_ERROR)

EndIf

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

If Not @error Then

Return SetError($SQL_OK, 0, $SQL_OK)

Else

$SQLErr = "Connection Error"

Return SetError($SQL_ERROR, 0, $SQL_ERROR)

EndIf

EndFunc

Func _SQL_Execute($hConHandle = -1, $vQuery = "")

$SQLErr = ""

Local $hQuery

If $hConHandle = -1 Then $hConHandle = $SQL_LastConnection

$hQuery = $hConHandle.Execute($vQuery)

If @error Then

Return SetError($SQL_ERROR, 0, $SQL_ERROR)

Else

Return SetError($SQL_OK, 0, $hQuery)

EndIf

EndFunc

Func _SQL_Close($ADODBHandle = -1)

$SQLErr = ""

If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection

If Not IsObj($ADODBHandle) Then

$SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"

Return SetError($SQL_ERROR, 0, $SQL_ERROR)

EndIf

$ADODBHandle.Close

If $ADODBHandle = $SQL_LastConnection Then $SQL_LastConnection = ""

Return SetError($SQL_OK, 0, $SQL_OK)

EndFunc

Add a COM error handler to get more detail on the failure. The fact that it takes some time to fail implies that it can't resolve the server name, but the error handler will tell.

:D

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...