
27/04/2005, 00:45
|
 | | | Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 11 meses Puntos: 1 | |
Alguien ve el fallo Esta consulta antes me actualizaba y ya no, alguien ve lo que esta mal???
private void actualizacioncli(object sender, System.EventArgs e)
{
myConnection = new SqlConnection (connectionString);
string updateCmd;
if (nombre.Visible)
{
updateCmd = "UPDATE Clientes SET Nombre=@Nombre,Sede=@Sede,Descripcion=@Descripcion where Nombre=@NombreCombo";
}
else
{
updateCmd = "UPDATE Clientes SET Sede=@Sede,Descripcion=@Descripcion where Nombre=@NombreCombo";
}
myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Clear();
myCommand.Parameters.Add(new SqlParameter("@NombreCombo",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@NombreCombo"].Value = ComboClientes.SelectedItem.Value;
myCommand.Parameters.Add(new SqlParameter("@Nombre",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@Nombre"].Value = nombre.Text;
myCommand.Parameters.Add(new SqlParameter("@Sede",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@Sede"].Value = CliSede.Value;
myCommand.Parameters.Add(new SqlParameter("@Descripcion",
SqlDbType.NVarChar, 500));
myCommand.Parameters["@Descripcion"].Value = CliDescripcion.Value;
Response.Write(myCommand.CommandText);
myCommand.Connection.Open();
try
{
int numreg=myCommand.ExecuteNonQuery();
//MsgBox.alert("Cliente actualizado correctamente");
//Response.Write (numreg.ToString());
//Response.Redirect("Menuadministrador1.aspx?Oku=1") ;
}
catch (SqlException c)
{
if (c.Number == 2627)
mensage.Text = "ERROR: Este cliente ya existe";
else
mensage.Text = "ERROR: No se ha podido añadir el registro, por favor " +
"asegurese de que todo esta correctamente escrito, gracias";
}
myCommand.Connection.Close();
}
Gracias. |