AutoIT: ADODB.Connection method 'open' missing? - autoit

I want to use AutoIT to access a Maria DB via ADODB objects.
The creation of the ADODB.Connection object seems to work properly. But for some reason I cannot find, the open method fails. I am no AutoIT expert, but to me it does not look like the object had problems with the arguments.
The relevant lines of the code are:
$objConn = ObjCreate("ADODB.Connection")
ConsoleWrite("ADODB conn Error: " & #error & " - Typ: " & VarGetType($objConn) & #crlf)
$objConn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword)
ConsoleWrite("conn Error: " & #error & #crlf)
The second ConsoleWrite is not reached. The Output and error-message are:
ADODB conn Error: 0 - Typ: Object
"C:\Users\mischneider\Documents\Automation_Base\udf\mysql.au3" (29) : ==> The requested action with this object has failed.:
$objConn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" &
$sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword) $objConn^ ERROR
Can anyone tell what I'm doing wrong and how I can open the connection?
Many thanks in advance,
Michael

I found the reason of and could resolve the problem.
My custom function took $sDriver with following (wrong) default value:
[...]$sDriver = "(MySQL ODBC 3.51 Driver)", [...]
where parentheses () instead of braces {} were used. Correct is:
[...]$sDriver = "{MySQL ODBC 3.51 Driver}", [...]
The laptop screen is so small I didn't realize that. But inserting a working Connection string and then comparing it to the result of the concatenation char by char, I recognized the difference.
I hope this now documented accident will help others in my situation.
BR
Michael

Related

Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives

Microsoft 365 V2205, build 15225.20204
The following VBA macro used to work, and it still works when run manually. A couple of years ago, I am guessing that a change from Microsoft occurred, and it now returns the error code "an unexpected error has occurred" when Outlook automatically runs it. Can someone show me a fix for the rule/VBA that will allow the rule/VBA to:
On an incoming email
Mark it as high importance
Update the subject
Set a category “Bill”
Set a reminder
Here is the:
Rules description
Apply this rule after the message arrives
With ‘Your credit card statement is ready’ or ‘Your statement is ready for credit card ending’
And on this computer only
Mark it as high importance
And run Damian.PendingPaid1
Here is the VBA:
Sub PendingPaid1(Item As Outlook.MailItem)
Item.Categories = "Bill"
Item.Subject = Item.Subject & " " & Chr(150) & " Pending " & Chr(150) & " PAID " & Chr(150) & " 220"
Item.ReminderSet = True
Item.FlagDueBy = Date + 1 & Space(1) & "8:45 AM" ' Remind 1 day from now.
Item.ReminderTime = Date + 1 & Space(1) & "8:45 AM" ' Remind 1 day from now.
Item.Save
End Sub

SagePay encryption error

I'm trying to integrate a classic asp site into SagePay 3.00 and cannot get past the Status Detail: 5080 : Form transaction registration failed error.
I've been checking my encryption (using the Sage adapted rijndael.asp files) using the example Sage provide and I get a slightly different output i.e. about the first 25% of my output matches Sage's example. Unsure where to go from here unless anyone can suggest a better or more reliable way of generating the encrypted file.
The text I'm encrypting (when not comparing to SagePay's test data) is:
spCryptTxt = "VendorTxCode="& datediff("s",DateValue("September 11, 1963"),now()) & "-" & session("****SessionId") & "&Amount=" & formatNumber(rs("totalCost"),2)_
& "&Currency=GBP"_
& "&Description=***Conferenceregistration"_
& "&CustomerName=" & rs("firstname") & rs("surname")_
& "&CustomerEMail=" & rs("email")_
& "&BillingSurname=" & rs("surname")_
& "&BillingFirstnames=" & rs("firstname")_
& "&BillingAddress1=" & rs("contactAddress1")_
& "&BillingCity=" & rs("contactCity")_
& "&BillingPostCode=" & rs("contactPostcode")_
& "&BillingCountry=GB"_
& "&DeliveryFirstnames=" & rs("firstname")_
& "&DeliverySurname=" & rs("surname")_
& "&DeliveryAddress1=" & rs("contactAddress1")_
& "&DeliveryCity=" & rs("contactCity")_
& "&DeliveryPostCode=" & rs("contactPostcode")_
& "&DeliveryCountry=GB"_
& "&SuccessURL=http://www.*****.com/****/success.asp"_
& "&FailureURL=http://www.*****.com/****//failure.asp"
and this always gives the 5080 error.
Help!
Look in My Sage Pay, under Transactions > Invalid. Instead of the generic 5080 error, it should give you a more informative error code.

VBScript Dictionary Error

I'm stuck working on an old project created with classic ASP (VBScript).
I've found the dictionary collection type which seems to be what I need. However, it keeps telling me "This key is already associated with an element of this collection." when I try to load it from a database recordset.
Here is the code.
set objRS = objDBConn.Execute("SELECT AreaAbbrev, Area FROM tblArea WHERE CompanyID = 15")
Set areaDict = CreateObject("scripting.dictionary")
areaDict.CompareMode=vbTextCompare
WHILE NOT objRS.EOF
Response.Write(objRS("AreaAbbrev") & " ::: " & objRS("Area") & "<br />")
areaDict.add objRS("AreaAbbrev"), objRS("Area")
objRS.movenext
WEND
This is the output:
00K ::: Kellogg
00G ::: Girdler
Microsoft VBScript runtime error '800a01c9'
This key is already associated with an element of this collection
As you can see, "00G" is not the same as "00K". Can anyone tell me why this may be giving me this error?
Thanks!
After some further research, I found adding .Value in this line fixed the issue:
areaDict.add objRS("AreaAbbrev").Value, objRS("Area").Value

Compiler Error Message: BC30451: Name 'cmbY' is not declared

I am getting a non-declaration error in this code.
Line 23: If Not Page.IsPostBack Then
Line 24: cmbY.DataSource = rsFirehose("SELECT LeagueTypeKey, LeagueTypeDescription FROM LeagueType " & _**
Line 25: "WHERE LeagueTypeKey=0 or (Appkey=" & glngAppKey & " AND LeagueTypeKey IN (SELECT Distinct YKey FROM " & _
Line 26: "Division WHERE DivisionTypeKey=" & soaDivisionTypeBracket & ")) ORDER BY LeagueTypeDescription")
Line 24 is where the error is: it says that the name "cmbY" is not declared. How do I declare it?
To correct this error
1.Check the spelling of the control
2.Check the scope of the element
3.Check the member access operator
If you post your code then we can find it very well...so post your code

ASP Classic - Type mismatch: 'CInt' - Easy question

Having an issue with type conversion in ASP classic.
heres my code:
Set trainingCost = Server.CreateObject("ADODB.Recordset")
strSQL3 = "SELECT cost1 FROM tblMain WHERE (Booked = 'Booked') AND (Paid IS NULL) AND (PaidDate BETWEEN '01/04/" & startyear & "' AND '31/03/" & endyear & "')"
trainingCost.Open strSQL3, Connection
trainingCost.movefirst
totalTrainCost = 0
do while not trainingCost.eof
trainCost = trainingCost("cost1")
If NOT isNull(trainCost) then
trainCostStr = CStr(trainCost)
trainCostStr = Replace(trainCostStr, "£", "")
trainCostStr = Replace(trainCostStr, ",", "")
totalTrainCost = totalTrainCost + CInt(trainCostStr)
end if
trainingCost.movenext
loop
trainingCost.close
when I run this I get the following error:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CInt'
/systems/RFT/v1.2/Extract.asp, line 43
which is "totalTrainCost = totalTrainCost + CInt(trainCostStr)"
Im guessing that the problem is to do with the String value being uncastable to Int in which case is there any way to catch this error? I havent worked with asp classic much so any help would be usefull
cheers
-EDIT-
the type of column cost1 is String as it may contain a number or a sequence of chars eg £10.00 or TBC
You have a couple of choices. You can be proactive by checking ahead of time whether the value is numeric using the IsNumeric function:
If IsNumeric(trainCostStr) Then
totalTrainCost = totalTrainCost + CInt(trainCostStr)
Else
' Do something appropriate
End If
...or you can be reactive by using error catching; in Classic ASP probably easiest to define a function and use On Error Resume Next:
Function ConvertToInt(val)
On Error Resume Next
ConvertToInt = CInt(val)
If Err.Number <> 0 Then
ConvertToInt = Empty
Err.Clear
End If
End Function
Or return 0 or Null or whatever suits you, then use it in your trainCost code.
Note that CInt expects an integer and will stop at the first non-digit, so "123.45" comes back as 123. Look at the other conversions, CDouble, CCur, etc.
Rather than casting to a string, why not use CCur (Cast as Currency) so that your commas and any currency symbols (I think) are effectively ignored while doing arithmetic operations?
Potentially solving the wrong problem, depends on the type of Cost1 within the database but the code is looping through the records to generate a total.
strSQL3 = "SELECT sum(cost1) FROM tblMain WHERE (Booked = 'Booked') AND (Paid IS NULL) AND (PaidDate BETWEEN '01/04/" & startyear & "' AND '31/03/" & endyear & "')"
trainingCost.Open strSQL3, Connection
etc and just read off the value as a total.
I don't see why the RS is being looped to generate a sum when the database can do that work for you. All the conversion work it has generated just looks artifical.
Heh heh. Classic ASP. You have my pity :) Anyway,
On error resume next
And then on the next line, check that it worked.
Though maybe you want CDouble. Is that a function? I can't remember.

Resources