| Bug #53387 | ExecuteNonQuery produces an exception | ||
|---|---|---|---|
| Submitted: | 3 May 2010 18:35 | Modified: | 20 May 2010 8:46 |
| Reporter: | Carlos Nava | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / NET | Severity: | S1 (Critical) |
| Version: | 6.2.3.0 | OS: | Windows |
| Assigned to: | CPU Architecture: | Any | |
[10 May 2010 9:01]
Tonci Grgin
Hi Carlos and thanks for your report. Please attach full test case demonstrating this error. Please also include the relevant part of general MySQL server log and a value of SQL_MODE variable.
[11 May 2010 20:45]
Carlos Nava
This is the function where the problem is produced.
"NuevoCamino" is a string containing a windows path.
The commandStr generated is like this: "UPDATE DocumentoRevision SET Documento='OD-004.03', Camino='\\DOCUMENTOS\\ISO 9001\\GENERAL\\', Fichero='OD-004.03.DOC' WHERE Documento='OD004.03' AND Revisión=''"
I tested the commandStr wich produces error in the program directly in MySQL Query Browser without problems.
sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
---------------------------------------------------------------------------
private bool DocumentoRevisionGuardaDatos()
{
string commandStr;
MySqlConnection conn;
MySqlCommand command;
conn = new MySqlConnection(connStr);
bool Resultado = false;
conn.Open();
try
{
commandStr = "UPDATE DocumentoRevision SET " +
"Documento='" + NuevoDocumento + "', " +
"Camino='" + NuevoCamino + "', " +
"Fichero='" + NuevoFichero + "' " +
"WHERE Documento='" + Documento + "' AND Revisión='" + cnRevisión + "'";
command = new MySqlCommand(commandStr, conn);
command.ExecuteNonQuery();
Resultado = true;
}
catch (MySqlException ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
}
return Resultado;
}
-------- LOG ----------------------------------------------
100511 22:20:44 8 Connect root@localhost on documentos
8 Query SELECT @@sql_mode
8 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
8 Query SET NAMES utf8
8 Init DB documentos
8 Init DB documentos
100511 22:20:45 9 Connect root@localhost on documentos
9 Query SELECT @@sql_mode
9 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
9 Query SET NAMES utf8
9 Init DB documentos
9 Init DB documentos
9 Init DB documentos
9 Query SHOW VARIABLES LIKE 'character_set_server'
9 Query SELECT @@SQL_MODE
9 Query SHOW FULL COLUMNS FROM `documentos`.`documentopublicado`
8 Query show databases
9 Query SHOW CREATE TABLE `documentos`.`documentopublicado`
9 Query SELECT * FROM `documentos`.`documentopublicado`
8 Init DB documentos
8 Query SHOW FULL TABLES
8 Query SHOW COLUMNS FROM `año`
8 Query SHOW COLUMNS FROM `contrato`
8 Query SHOW COLUMNS FROM `contratocontacto`
8 Query SHOW COLUMNS FROM `contratopersonal`
8 Query SHOW COLUMNS FROM `contratosuministrador`
8 Query SHOW COLUMNS FROM `departamento`
8 Query SHOW COLUMNS FROM `desplazamiento`
8 Query SHOW COLUMNS FROM `documento`
8 Query SHOW COLUMNS FROM `documentoestado`
8 Query SHOW COLUMNS FROM `documentomodificar`
8 Query SHOW COLUMNS FROM `documentopublicado`
8 Query SHOW COLUMNS FROM `documentorelacionado`
8 Query SHOW COLUMNS FROM `documentorevision`
8 Query SHOW COLUMNS FROM `envío`
8 Query SHOW COLUMNS FROM `envíodestinatario`
8 Query SHOW COLUMNS FROM `envíodocumento`
8 Query SHOW COLUMNS FROM `envíopreguntas`
8 Query SHOW COLUMNS FROM `envíopreguntasrespuestas`
8 Query SHOW COLUMNS FROM `ficheros`
8 Query SHOW COLUMNS FROM `idioma`
8 Query SHOW COLUMNS FROM `informes`
8 Query SHOW COLUMNS FROM `nivelusuario`
8 Query SHOW COLUMNS FROM `pedido`
8 Query SHOW COLUMNS FROM `personal`
8 Query SHOW COLUMNS FROM `personaldepartamento`
8 Query SHOW COLUMNS FROM `programa`
8 Query SHOW COLUMNS FROM `rc`
8 Query SHOW COLUMNS FROM `rccontactos`
8 Query SHOW COLUMNS FROM `rcofertas`
8 Query SHOW COLUMNS FROM `servidor`
8 Query SHOW COLUMNS FROM `sociedad`
8 Query SHOW COLUMNS FROM `sociedadcategoria`
8 Query SHOW COLUMNS FROM `sociedadtiposuministro`
8 Query SHOW COLUMNS FROM `suministradortiposuministro`
8 Query SHOW COLUMNS FROM `tipodocumento`
8 Query SHOW COLUMNS FROM `tiposuministro`
8 Init DB documentos
8 Init DB documentos
8 Query SHOW PROCEDURE STATUS
8 Query SHOW FUNCTION STATUS
8 Init DB documentos
100511 22:20:46 9 Quit
10 Connect root@localhost on documentos
10 Query SELECT @@sql_mode
10 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
10 Query SET NAMES utf8
10 Init DB documentos
10 Init DB documentos
100511 22:20:47 11 Connect root@localhost on documentos
11 Query SELECT @@sql_mode
11 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
11 Query SET NAMES utf8
11 Init DB documentos
11 Init DB documentos
100511 22:30:48 7 Init DB documentos
7 Query UPDATE Documento SET DocumentoAD='OD-004.02' WHERE DocumentoAD='OD04.02'
7 Query UPDATE DocumentoPublicado SET Documento='OD-004.02' WHERE Documento='OD04.02'
7 Query UPDATE DocumentoRelacionado SET Documento='OD-004.02' WHERE Documento='OD04.02'
7 Query UPDATE DocumentoRelacionado SET DocRelacionado='OD-004.02' WHERE DocRelacionado='OD04.02'
6 Init DB documentos
6 Query UPDATE DocumentoModificar SET Hecho = 1,DocumentoNuevo = 'OD-004.02' WHERE Documento = 'OD04.02'
7 Init DB documentos
6 Init DB documentos
7 Init DB documentos
100511 22:37:57 7 Init DB documentos
7 Query UPDATE Documento SET DocumentoAD='OD-004.03' WHERE DocumentoAD='OD004.03'
7 Query UPDATE DocumentoPublicado SET Documento='OD-004.03' WHERE Documento='OD004.03'
7 Query UPDATE DocumentoRelacionado SET Documento='OD-004.03' WHERE Documento='OD004.03'
7 Query UPDATE DocumentoRelacionado SET DocRelacionado='OD-004.03' WHERE DocRelacionado='OD004.03'
6 Init DB documentos
6 Query UPDATE DocumentoModificar SET Hecho = 1,DocumentoNuevo = 'OD-004.03' WHERE Documento = 'OD004.03'
7 Init DB documentos
6 Init DB documentos
7 Init DB documentos
[12 May 2010 11:53]
Tonci Grgin
Carlos, what happens if you add NO_BACKSLASH_ESCAPES to SQL_MODE?
[12 May 2010 18:08]
Carlos Nava
Adding NO_BACKSLASH_ESCAPES it works fine. Thank you.
[20 May 2010 8:46]
Tonci Grgin
Carlos, glad things work now. If you want the same effect without changing SQL_MODE your commandstring should look like Path='\\\\Folder1\\\\Folder2\\\\Folder3\\\\' Closing as there is no bug here.

Description: If the command string passed to ExecuteNonQuery() contains the backslash ('\\') an exception is produced. How to repeat: commandStr = "UPDATE DocumentRev SET Path='\\Folder1\\Folder2\\Folder3\\' WHERE Document='OD02' AND Rev='a'"; command = new MySqlCommand(commandStr, conn); command.ExecuteNonQuery();