Problem whit MySql CONCAT()
Problem whit MySql CONCAT()
With the "CoreLab Library", the result of a query that uses the concat () was a column of type System.String, and now with the "Devart Library" the result is a System.byte []. What to do to change my whole solution?
Thanks.
Thanks.
I have tried the following code with the 5.80.170 version of dotConnect for MySQL. My output is "System.String". Please tell us your current version of dotConnect for MySQL (Tools > MySQL > About) and MySQL Server. How should we modify this sample to reproduce the issue?
Code: Select all
using (MySqlConnection conn = new MySqlConnection("server=db;port=3309;database=test;uid=***;pwd=***;")) {
MySqlDataTable table = new MySqlDataTable("select concat('D','e','v','a','r','t')", conn);
table.FetchAll = true;
table.Open();
Console.WriteLine(table.Columns[0].DataType.ToString()); // "System.String"
}
The problem occurs on concat () with evaluation type string and numeric columns.
CREATE TABLE `nodo` (
`Id` int(11) NOT NULL auto_increment,
`codice` int(10) NOT NULL default '0',
`DescNodo` varchar(60) NOT NULL default '',
`DescNodoTD` varchar(20) NOT NULL default '',
`DescRiferimento` varchar(40) NOT NULL default '',
`Codice_TipoNodo` varchar(50) NOT NULL default '',
`Id_Comune` int(11) default NULL,
`Longitudine` decimal(12,6) NOT NULL,
`Latitudine` decimal(12,6) NOT NULL,
`DistanzaIn` int(11),
`DistanzaOut` int(11),
`FlgTiddy` enum('S','N') NOT NULL default 'N',
`IdNodoCol` int(11) default NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `UKDescNodo` USING BTREE (`DescNodo`,`DescRiferimento`),
KEY `Id_Comune` (`Id_Comune`),
KEY `KIdNodoCol` (`IdNodoCol`),
CONSTRAINT `0_542` FOREIGN KEY (`Id_Comune`) REFERENCES `comune` (`id`),
CONSTRAINT `FKIdNodoCol` FOREIGN KEY (`IdNodoCol`) REFERENCES `nodo` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
StringBuilder oSql = new StringBuilder();
oSql.Append("SELECT Concat(Descnodo,'(',DescRiferimento,')') Descrizione, ");
oSql.Append("Concat('Long. ',Longitudine,'Lat. ',Latitudine) Coordinate ");
oSql.Append("FROM nodo ");
MySqlCommand oCmd = new MySqlCommand(oSql.ToString(), VariabiliGlobali.oConn);
MySqlDataReader oNodi = oCmd.ExecuteReader();
while (oNodi.Read()) {
Console.WriteLine(oNodi["Descrizione"].GetType().ToString()); //System.String
Console.WriteLine(oNodi["Coordinate"].GetType().ToString()); //System.Byte[]
}
oNodi.Close();
CREATE TABLE `nodo` (
`Id` int(11) NOT NULL auto_increment,
`codice` int(10) NOT NULL default '0',
`DescNodo` varchar(60) NOT NULL default '',
`DescNodoTD` varchar(20) NOT NULL default '',
`DescRiferimento` varchar(40) NOT NULL default '',
`Codice_TipoNodo` varchar(50) NOT NULL default '',
`Id_Comune` int(11) default NULL,
`Longitudine` decimal(12,6) NOT NULL,
`Latitudine` decimal(12,6) NOT NULL,
`DistanzaIn` int(11),
`DistanzaOut` int(11),
`FlgTiddy` enum('S','N') NOT NULL default 'N',
`IdNodoCol` int(11) default NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `UKDescNodo` USING BTREE (`DescNodo`,`DescRiferimento`),
KEY `Id_Comune` (`Id_Comune`),
KEY `KIdNodoCol` (`IdNodoCol`),
CONSTRAINT `0_542` FOREIGN KEY (`Id_Comune`) REFERENCES `comune` (`id`),
CONSTRAINT `FKIdNodoCol` FOREIGN KEY (`IdNodoCol`) REFERENCES `nodo` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
StringBuilder oSql = new StringBuilder();
oSql.Append("SELECT Concat(Descnodo,'(',DescRiferimento,')') Descrizione, ");
oSql.Append("Concat('Long. ',Longitudine,'Lat. ',Latitudine) Coordinate ");
oSql.Append("FROM nodo ");
MySqlCommand oCmd = new MySqlCommand(oSql.ToString(), VariabiliGlobali.oConn);
MySqlDataReader oNodi = oCmd.ExecuteReader();
while (oNodi.Read()) {
Console.WriteLine(oNodi["Descrizione"].GetType().ToString()); //System.String
Console.WriteLine(oNodi["Coordinate"].GetType().ToString()); //System.Byte[]
}
oNodi.Close();
Server returns binary data for the Coordinate column. The 4.85.36 version of our provider converts binary to System.String() in the default encoding implicitly. But we decided that the right approach in this case is to return data as is (byte[]) in order to allow users to convert data in strings with the necessary encoding if needed.
You can use the following methods to obtain results of the previous version: reader.GetString(colId) or reader.GetMySqlBinaryString(colId). The reader.GetDataTypeName(colID) method returns the server type.
You can use the following methods to obtain results of the previous version: reader.GetString(colId) or reader.GetMySqlBinaryString(colId). The reader.GetDataTypeName(colID) method returns the server type.
Code: Select all
while (oNodi.Read()) {
Console.WriteLine(oNodi["Descrizione"].GetType().ToString());
Console.WriteLine(oNodi.GetString(oNodi.GetOrdinal("Coordinate")).GetType().ToString());
}
oNodi.Close();
There will be plenty confuzione in source code.
You will never have the certainty of the result.
The query "SHOW CREATE TABLE datigps" columns System.byte returns [].
In MySQL, there are no columns byte [].
Wonder if you can insert a parameter to allow for MySqlConnection copatibilità earlier.
In recent years I have developed a variety of applications, which now in danger of crashing.
You will never have the certainty of the result.
The query "SHOW CREATE TABLE datigps" columns System.byte returns [].
In MySQL, there are no columns byte [].
Wonder if you can insert a parameter to allow for MySqlConnection copatibilità earlier.
In recent years I have developed a variety of applications, which now in danger of crashing.
New build of dotConnect for MySQL 5.80.180 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=19238 .
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=19238 .
Re: Problem whit MySql CONCAT()
Why dont you post a solution to the problem.
I hav just upgraded from 4.85 to 7.06 and experience the same problems. My application crashes at every statement with "CONCAT". What is the solution to this?
I hav just upgraded from 4.85 to 7.06 and experience the same problems. My application crashes at every statement with "CONCAT". What is the solution to this?