DoctorSLO Posted June 19, 2009 Share Posted June 19, 2009 (edited) 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: expandcollapse popup$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 June 19, 2009 by DoctorSLO Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 19, 2009 Share Posted June 19, 2009 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.364When 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()ExitFunc _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 EndFuncFunc _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) EndIfEndFuncFunc _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) EndIfEndFuncFunc _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)EndFuncAdd 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. 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 More sharing options...
Zedna Posted June 19, 2009 Share Posted June 19, 2009 You have bad DSN string for MySQL.Look here for right DSN strings for various databases:http://www.carlprothman.net/Default.aspx?tabid=81 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
DoctorSLO Posted June 19, 2009 Author Share Posted June 19, 2009 (edited) Ok I found this: http://www.autoitscript.com/forum/index.php?showtopic=20814and now its works ....I forgot to search for MySQL .... I was searching only for SQL sry for spam Edited June 19, 2009 by DoctorSLO Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now