Foros del Web » Programación para mayores de 30 ;) » .NET »

Error update en Excel

Estas en el tema de Error update en Excel en el foro de .NET en Foros del Web. Hola tengo un problema al intentar realizar un update csobre un archivo de excel mediante una conexion OLE EDITO: algo que se me pasó ( ...
  #1 (permalink)  
Antiguo 20/11/2013, 10:04
Avatar de lair  
Fecha de Ingreso: enero-2009
Ubicación: header('Location: Morelia");
Mensajes: 1.052
Antigüedad: 15 años, 3 meses
Puntos: 46
Error update en Excel

Hola tengo un problema al intentar realizar un update csobre un archivo de excel mediante una conexion OLE

EDITO: algo que se me pasó ( no se si es relevante ) está hoja solo tiene esos dos campos "Correo" y "verificado" ( alfanumerico y numerico respectivamente )

les paso como lo estoy haciendo y el error que me marca.
Código C#:
Ver original
  1. using (OleDbConnection objConn = new OleDbConnection(Source.ToString()))
  2.             {
  3.  
  4.  
  5.                 try
  6.                 {
  7.                     objConn.Open();
  8.                     OleDbCommand objCmdSelect = new OleDbCommand(@"update [Hoja1$] set verificado = " + 1 + " where Correo = '" + usuario.Correo + "' and verificado = 0;", objConn);
  9.                     objCmdSelect.CommandType = System.Data.CommandType.Text;
  10.  
  11.                     objCmdSelect.ExecuteNonQuery();
  12.                 }
  13.                 catch (Exception ex)
  14.                 {
  15.                     Console.WriteLine(ex.Message);
  16.                 }
  17.                 finally
  18.                 {
  19.                     objConn.Close();
  20.                 }
  21.             }


también lo he intentado así:
Código C#:
Ver original
  1. try
  2.                 {
  3.                     objConn.Open();
  4.                     OleDbCommand objCmdSelect = new OleDbCommand(@"update [Hoja1$] set verificado = 1 where Correo = @Correo and verificado = 0;", objConn);
  5.                     objCmdSelect.Parameters.Add(new OleDbParameter("@Correo", OleDbType.VarChar) { Value = usuario.Correo });
  6.  
  7.                     objCmdSelect.ExecuteNonQuery();
  8.                 }
  9.                 catch (Exception ex)
  10.                 {
  11.                     Console.WriteLine(ex.Message);
  12.                 }
  13.                 finally
  14.                 {
  15.                     objConn.Close();
  16.                 }

pero en ambos casos obtengo este error:
Cita:
No se han especificado valores para algunos de los parámetros requeridos.
esto es lo que tiene en la "exception.ToString"
Cita:
System.Data.OleDb.OleDbException (0x80040E10): No se han especificado valores para algunos de los parámetros requeridos.
en System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr)
en System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult)
en System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method)
en System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
en registrosIntellegoToID.Program.Verificado(oleConne ction Source, Usuario usuario) en d:\www\Apps\registros\registros\Program.cs:línea 250
NOTA 1: tengo operaciones de Insert y Select y estas funcionan perfectamente.
NOTA 2: la linea 250 que marca la excepcion es la instruccion "ExecuteNonQuery" del comando

Saludos y gracias por su tiempo.

Última edición por lair; 20/11/2013 a las 10:14 Razón: agrego información

Etiquetas: csharp, excel, update
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:26.