Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/07/2009, 14:00
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Problemas con C#

Tengo el código este. En MySQL me funciona bajo phpMyAdmin este código sin problemas pero no Visual C#. ¿Cómo lo soluciono?

Código:
private void button_actualizar_Click(object sender, EventArgs e)
        {
            string insertar_disp = @"UPDATE `dispositivos` SET descripcion='descripcion1' WHERE id='1';
                                     UPDATE `dispositivos` SET descripcion='descripcion2' WHERE id='2';
                                     UPDATE `dispositivos` SET descripcion='descripcion3' WHERE id='3';
                                     UPDATE `dispositivos` SET descripcion='descripcion4' WHERE id='4';";
                                            

            connection = new MySqlConnection(MyConString);
            MySqlCommand con7 = new MySqlCommand(insertar_disp, connection);
            connection.Open();
            con7.ExecuteNonQuery();
            connection.Close();
        }

Datos de MySQL es:
Código:
CREATE TABLE IF NOT EXISTS `dispositivos` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(6) COLLATE latin1_spanish_ci NOT NULL,
  `estado` tinyint(2) NOT NULL,
  `descripcion` varchar(20) COLLATE latin1_spanish_ci NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci AUTO_INCREMENT=5 ;

--
-- (Evento) desencadenante `dispositivos`
--
DROP TRIGGER IF EXISTS `pic_remoto`.`logestado`;
DELIMITER //
CREATE TRIGGER `pic_remoto`.`logestado` AFTER UPDATE ON `pic_remoto`.`dispositivos`
 FOR EACH ROW BEGIN

                                   DECLARE Rele1 INT;
                                   DECLARE Rele2 INT;
                                   DECLARE Rele3 INT;
                                   DECLARE Rele4 INT;

                                   SET Rele1 = (SELECT estado
                                   FROM dispositivos
                                   WHERE nombre LIKE 'RELE 1');

                                   SET Rele2 = (SELECT estado
                                   FROM dispositivos
                                   WHERE nombre LIKE 'RELE 2');

                                   SET Rele3 = (SELECT estado
                                   FROM dispositivos
                                   WHERE nombre LIKE 'RELE 3');

                                   SET Rele4 = (SELECT estado
                                   FROM dispositivos
                                   WHERE nombre LIKE 'RELE 4');

                                   INSERT INTO log(RELE_1, RELE_2, RELE_3, RELE_4, USUARIO, FECHA_HORA)
                                   VALUES (Rele1, Rele2, Rele3, Rele4, USER(), NOW());
                             END
//
DELIMITER ;

--
-- Volcar la base de datos para la tabla `dispositivos`
--

INSERT INTO `dispositivos` (`ID`, `nombre`, `estado`, `descripcion`) VALUES
(1, 'RELÉ 1', 0, 'vacío'),
(2, 'RELÉ 2', 0, 'vacío'),
(3, 'RELÉ 3', 0, 'vacío'),
(4, 'RELÉ 4', 0, 'vacío');
Me da error:
No se controló System.ArgumentNullException
Message="La clave no puede ser nula.\r\nNombre del parámetro: key"
Source="mscorlib"
ParamName="key"
StackTrace:
en System.Collections.Hashtable.get_Item(Object key)
en MySql.Data.MySqlClient.MySqlPoolManager.GetPool(My SqlConnectionStringBuilder settings)
en MySql.Data.MySqlClient.MySqlConnection.Open()
en MySQL12.Form1.button_actualizar_Click(Object sender, EventArgs e) en C:\Documents and Settings\Hunter\Mis documentos\Visual Studio 2008\Projects\MySQL12\MySQL12\Form1.cs:línea 157
en System.Windows.Forms.Control.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.ButtonBase.WndProc(Message& m)
en System.Windows.Forms.Button.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
en System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
en System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
en System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
en System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
en System.Windows.Forms.Application.Run(Form mainForm)
en MySQL12.Program.Main() en C:\Documents and Settings\Hunter\Mis documentos\Visual Studio 2008\Projects\MySQL12\MySQL12\Program.cs:línea 18
en System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context( Object state)
en System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()
InnerException:
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar