Page 1 of 1
XS0121 The call is ambiguous ...MySQL.Data
Posted: Mon Feb 01, 2021 4:58 pm
by ic2
I installed the previous X# and as a result immediately got some new errors. From one I don't understand why my fix didn't change it:
Error XS0121 The call is ambiguous between the following methods or properties: 'MySql.Data.MySqlClient.MySqlDataReader.GetString(string)' and 'System.Data.Common.DbDataReader.GetString(int)'
Code line is:
cValue:=Trim(oSQLrdr:GetString(AFields[ni]))
so I changed
Local oSQLrdr As MySqlDataReader
to
Local oSQLrdr As MySQL.Data.MySQLClient.MySqlDataReader
Why doesn't adding the namespace to the variable definition not solve this error?
Dick
XS0121 The call is ambiguous ...MySQL.Data
Posted: Mon Feb 01, 2021 5:54 pm
by robert
Dick,
Most likeliy you are using a VO style array in aFields{}. The values in this array are of type USUAL.
At compile time the type of the contents of the USUAL is know known.
And there are runtime conversions available from USUAL to both Int and String.
So the compiler has no idea which of the two overloads you want to call.
If you know that the array contains strings you can add change the code to GetString( (String) aFields[ni] )
when you know that the array contains numbers then you can change the code to GetString ( (int) aFields[nI] ).
Robert
XS0121 The call is ambiguous ...MySQL.Data
Posted: Wed Feb 03, 2021 9:20 pm
by ic2
Hello Robert,
Thanks for the reply, but when I change the line to:
cValue:=Trim(oSQLrdr:GetString(String)(AFields[ni]))
the error changes to:
Error XS0149 Method name expected
This is not explained in the help so I have no idea what to do next.
It used to work in earlier version. Can't I do something that it works without changing the code?
Although I understand that it's probably a good idea to tighten the compiler but it makes me very reluctant to update to a new version if I have to fix all kind of code lines which used to work fine before. I was using the July 2020 version until last week.
Dick
XS0121 The call is ambiguous ...MySQL.Data
Posted: Wed Feb 03, 2021 9:29 pm
by robert
Dick,
The text (String) has to come between the open parenthesis from GetString and aFields:
Code: Select all
cValue:=Trim(oSQLrdr:GetString((String)AFields[ni]))
Or you use a temp variable:
Code: Select all
cValue := AFields[ni]
cValue := Trim(oSQLrdr:GetString(cValue))
Robert
XS0121 The call is ambiguous ...MySQL.Data
Posted: Thu Feb 04, 2021 4:29 pm
by ic2
Hello Robert,
The 2 step second suggestion compiles fine now and is also a lot more readable; thanks.
Dick