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

Update embebido

Estas en el tema de Update embebido en el foro de .NET en Foros del Web. Como ves es VB y lo tuyo C#, es para no liarme, bueno, sigo....

  #31 (permalink)  
Antiguo 10/05/2005, 09:44
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Como ves es VB y lo tuyo C#, es para no liarme, bueno, sigo.
  #32 (permalink)  
Antiguo 10/05/2005, 09:51
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Primero, perdón,en el while que te he puesto serían donde fuesen = al arr(i) no <>

dim i as integer = 0
while i< arr.length
mycommand.connection.open();
mycommand.commandtext = " Insert into UsuariosServicios (UsServIdServ,UsServIdUs) values(" & arr(i) &"," & ComboLogin.SelectedItem.Value &")"
mycommand.coneection.close();

i+=1
endwhile

Con esto insertarías todos aquellos que hayan sido seleccionados.

Ahora, te faltaría solamente una cosa, y es cargar el

<input type="text"> Los valores de los checks que están seleccionados de inicio en el mismo momento de cargar los checks
  #33 (permalink)  
Antiguo 10/05/2005, 09:56
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Para ello, crearemos una variable de tipo publico para toda la página

public valordelinput as string =""

y en el momento de cargar el listado haremos lo siguiente

if (reader4["UsServIdUs"].ToString()=="")
{
...
}
else
{
valordelinput += reader4["ServId"];
}

Con esto ya tendremos cargado correctamente el textbox.

Esto es solo a modo orientativo, espero que te sea lo que buscas, si tienes cualquier duda....

jejeje, vaya trio (de programadores, no sexual, eh??) formamos
  #34 (permalink)  
Antiguo 10/05/2005, 09:59
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
boton actualizar

El boton de actualizar lo tengo asi:

<asp:linkbutton id="actualizar" runat="server" CssClass="botones actualizar">Actualizar</asp:linkbutton>

Tendria que poner:
<a href="javascript:;" onclick="__doPostBack("Guardar",document.getElemen tbyId("text").value);">Lo que sea</a>


y que es text???? el id de la label supongo???
  #35 (permalink)  
Antiguo 10/05/2005, 10:05
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
exacto pero las comillas de dentro de las dobles serían simples y el by con mayusculas

<href="javascript:;" onclick="__doPostBack("Guardar",document.getElemen tById('text').value);">Actualizar</a>

text es el input de type="text" y con id="text" al que te hemos hecho referencia

<input type="text" id="text" width="0" value=<%= valordelinput %>>

Este campo de texto lo utilizamos de comodín y de modo invisible para almacenar del lado del cliente los checkbox que se seleccionan o que se quitan, sin necesidad de ir cada vez al servidor. Así sólo actualizaremos en el momento de dar a Actualizar
  #36 (permalink)  
Antiguo 10/05/2005, 10:15
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
error

me dice que no se puede volver a dar formato debido a la linea esta:

<a href="#" class="botones actualizar" onclick="__doPostBack("Guardar",document.getElemen tById('text').value);">Actualizar</a>

y yo creo que esta correcta no???
  #37 (permalink)  
Antiguo 10/05/2005, 10:20
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
vale ya esta eso

pero tengo un problemita con csharp, no se como se pone para declarar un array y sobre todo para pasar por valor el array?????
  #38 (permalink)  
Antiguo 10/05/2005, 10:23
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Añade esto en el page load de tu página, FUERA del if !PostBack...

Page.GetPostBackEventReference(Page)
  #39 (permalink)  
Antiguo 10/05/2005, 10:27
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
me falla esto

if (Request.Form["__eventtarget"].ToString() == "guardar")
{
string identificadores = Request.Form["__eventargument"];
System.Array dentificadores= identificadores.Split("");
//CambiaServicios(arrayidentificadores);
}

no consigo que me coja esto
  #40 (permalink)  
Antiguo 10/05/2005, 10:28
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
array arrayidentificadores = identificadores.split("");

y para pasarlo igual

NombreFuncion(array)

y para recibirlo

private void NombreFuncio(array arr)

En esta página tienes un convertidor de codigo de c# a VB y viceversa
http://www.developerfusion.com/utili...sharptovb.aspx
  #41 (permalink)  
Antiguo 10/05/2005, 10:29
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
A que te refieres con que no te lo coje,

no te compila???

te hace el postback pero no se mete???

te da error??
  #42 (permalink)  
Antiguo 10/05/2005, 10:30
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
si no te compila sería

if this.request.Form["__eventtarget"]
  #43 (permalink)  
Antiguo 10/05/2005, 10:45
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
error

Por ahora llevo esto:

if (Request.Form["__eventtarget"].ToString() == "guardar")
{
string identificadores = Request.Form["__eventargument"];
Array arrayidentificadores = identificadores.Split("");
CambiaServicios(arrayidentificadores);
}

el boton actualizar:

<A class="botones actualizar" runat=server onclick="__doPostBack('Guardar',document.getElemen tById('text').value);"
href="#">Actualizar</A>&nbsp;

el input text:

<INPUT id="text" type="text" size="8">

y la funcion:

private void CambiaServicios(Array arr)
{
myConnection = new SqlConnection (connectionString);
string updateCmd;

if (ConfUsPass.Visible)
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsPass=@UsPass,UsMail=@UsMail,U sTelefono=@UsTelefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
else
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsMail=@UsMail,UsTelefono=@UsTe lefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@UsId",
SqlDbType.Int, 4));
myCommand.Parameters["@UsId"].Value = ComboLogin.SelectedItem.Value;
myCommand.Parameters.Add(new SqlParameter("@UsNombre",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsNombre"].Value = UsNombre.Value;
myCommand.Parameters.Add(new SqlParameter("@UsPass",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsPass"].Value = UsPass.Value;
myCommand.Parameters.Add(new SqlParameter("@UsMail",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsMail"].Value = UsMail.Value;
myCommand.Parameters.Add(new SqlParameter("@UsTelefono",
SqlDbType.NVarChar, 15));
myCommand.Parameters["@UsTelefono"].Value = UsTelefono.Value;
myCommand.Parameters.Add(new SqlParameter("@UsIdPer",
SqlDbType.Int, 4));
myCommand.Parameters["@UsIdPer"].Value = UsPerfil.SelectedItem.Value;
myCommand.Connection.Open();
try
{
if ((ConfUsPass.Visible) && (UsPass.Value!=ConfUsPass.Value))
MsgBox1.alert("El password no es correcto");
else
{
int numreg=myCommand.ExecuteNonQuery();
//updateservicios();
Response.Redirect("MenuadministradorUsu.aspx?Oku=1 &Nombre="+Request.QueryString["Nombre"].ToString()+"&Id="+Request.QueryString["id"].ToString()+"&mod="+ComboLogin.SelectedItem.Value) ;
//Response.Redirect("Menuadministrador1.aspx?Oku=1&m od="+nombre.Text);
}
}
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();

string sql;
int i=0;
while (i< arr.length)
{
if (i==0)
sql = " where UsServIdServ==" & arr[i];
else
sql += " and UsServIdServ==" & arr[i];
i+=1;
}
sql = "Delete from UsuariosServicios " + sql + " and UsServIdUs=" & ComboLogin.SelectedItem.Value;
myCommand.Connection.Open();
myCommand.CommandText = sql;
}
  #44 (permalink)  
Antiguo 10/05/2005, 10:49
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
ok, yo me tengo pirar ya, así que mañana me cuentas.

Por cierto rootk, si lees este mensaje, tengo una duda pendiente con mi WebService, echame un cable

jajajaja
  #45 (permalink)  
Antiguo 11/05/2005, 00:23
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
continuacion

MIra me da errores aki:

if (Request.Form["__eventtarget"].ToString() == "guardar")
{
string identificadores = Request.Form["__eventargument"];
Array arrayidentificadores = identificadores.Split("");
CambiaServicios(arrayidentificadores);
}

Me dice que identificadores.split el parametro que le paso no es correcto.

A parte no entiendo muy bien esta parte:
if (reader4["UsServIdUs"].ToString()=="")
{
...
}
else
{
valordelinput += reader4["ServId"];
}
  #46 (permalink)  
Antiguo 11/05/2005, 00:54
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Respecto a lo segundo, lo que hacemos es en la instrucción en la que generabamos los checkbox, pues en caso de que el checkbox aparezca seleccionado, asignamos el valor del id del servicio a la variable 'valordelinput', la cual representará posteriormente el .value de input invisible, para que este ya aparezca correctamente cargado con los valores seleccionados, es decir si el usuario x tiene los servicios 1 y 3, éstos además de aparecer seleccionados, hemos de decirle al objeto input que su value inicial debe ser '13'

Entiendes???

Respecto a lo segundo, es porque no te deja pasar el carcater vacío, por lo que vamos a hacer unos pequeños cambios:

Atiende:

if (reader4["UsServIdUs"].ToString()=="")
{
...
}
else
{
valordelinput += "#" reader4["ServId"];
}


función javascript del add:

function add(valor)
{
var inf = document.getElementById('text').value;
if (inf.indexOf(valor)==-1)
{
document.getElementById('textoprueba').value = document.getElementById('text').value + '#' + valor;

}
else
{
document.getElementById('text').value = document.getElementById('text').value.replace('#'+ valor,'');
}
}

Y por último en el split, en vez de meter Split("); metemos Split("#");

PD. El simbolo # es un simbolo comodín, puedes usar cualquier otro que sepas que nunca va a aperecer en ServId
  #47 (permalink)  
Antiguo 11/05/2005, 01:02
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
la funcion add ya esta cambiada, y esto ke me pones:

if (reader4["UsServIdUs"].ToString()=="")
{
...
}
else
{
valordelinput += "#" reader4["ServId"];
}

en mi caso seria

esto:

if (reader4["UsServIdUs"].ToString()=="")
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
Servicios.Text+="<br>";
}
else
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' CHECKED value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
text.Value+="#"+reader4["ServId"]; Servicios.Text+="<br>";
}

por cierto el split me sigue dando error, string .split(params.chars) tiene algunos argumentos no validos
  #48 (permalink)  
Antiguo 11/05/2005, 01:22
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
Y esto???

private void CambiaServicios(Array arr)
{
myConnection = new SqlConnection (connectionString);
string updateCmd;

if (ConfUsPass.Visible)
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsPass=@UsPass,UsMail=@UsMail,U sTelefono=@UsTelefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
else
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsMail=@UsMail,UsTelefono=@UsTe lefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@UsId",
SqlDbType.Int, 4));
myCommand.Parameters["@UsId"].Value = ComboLogin.SelectedItem.Value;
myCommand.Parameters.Add(new SqlParameter("@UsNombre",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsNombre"].Value = UsNombre.Value;
myCommand.Parameters.Add(new SqlParameter("@UsPass",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsPass"].Value = UsPass.Value;
myCommand.Parameters.Add(new SqlParameter("@UsMail",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsMail"].Value = UsMail.Value;
myCommand.Parameters.Add(new SqlParameter("@UsTelefono",
SqlDbType.NVarChar, 15));
myCommand.Parameters["@UsTelefono"].Value = UsTelefono.Value;
myCommand.Parameters.Add(new SqlParameter("@UsIdPer",
SqlDbType.Int, 4));
myCommand.Parameters["@UsIdPer"].Value = UsPerfil.SelectedItem.Value;
myCommand.Connection.Open();
try
{
if ((ConfUsPass.Visible) && (UsPass.Value!=ConfUsPass.Value))
MsgBox1.alert("El password no es correcto");
else
{
int numreg=myCommand.ExecuteNonQuery();
//updateservicios();
Response.Redirect("MenuadministradorUsu.aspx?Oku=1 &Nombre="+Request.QueryString["Nombre"].ToString()+"&Id="+Request.QueryString["id"].ToString()+"&mod="+ComboLogin.SelectedItem.Value) ;
//Response.Redirect("Menuadministrador1.aspx?Oku=1&m od="+nombre.Text);
}
}
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();

string sql;
int i=0;
while (i< arr.length)
{
if (i==0)
sql = " where UsServIdServ==" & arr[i];
else
sql += " and UsServIdServ==" & arr[i];
i+=1;
}
sql = "Delete from UsuariosServicios " + sql + " and UsServIdUs=" & ComboLogin.SelectedItem.Value;
myCommand.Connection.Open();
myCommand.CommandText = sql;

}

asi seria para el delete pero para el insert???
es que estoy un poco perdido con lo del __doPostBack
  #49 (permalink)  
Antiguo 11/05/2005, 01:24
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
En tu caso sería

if (reader4["UsServIdUs"].ToString()=="")
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
Servicios.Text+="<br>";
}
else
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' CHECKED value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
VARIABLEPUBLICA+="#"+reader4["ServId"]; Servicios.Text+="<br>";
}

No puedes hacer referencia a un elemento html en el server puesto que todavía NO se ha generado, por eso usamos una variable pública de tipo string, para luego en el html poner:

<input type="text" id="text" value=<%= VARIABLEPUBLICA %>>

Entiendes??
  #50 (permalink)  
Antiguo 11/05/2005, 01:33
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
ya esta lo de la variable publica

Ya he creado una variable publica:

public class MenuadministradorUsu : System.Web.UI.Page
{
SqlConnection myConnection;
SqlCommand myCommand;
string VARIABLEPUBLICA;

y la meti asi:

if (reader4["UsServIdUs"].ToString()=="")
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
Servicios.Text+="<br>";
}
else
{
Servicios.Text+="<input class='checkbox' onclick='javascript:add(" + reader4["ServId"] +");' id='" + reader4["ServNombre"].ToString() + "' title='" + reader4["ServNombre"].ToString() + "' type='checkbox' CHECKED value='" + reader4["ServNombre"].ToString() + "' name='" + reader4["ServNombre"].ToString() + "'>";
Servicios.Text+=reader4["ServNombre"].ToString();
VARIABLEPUBLICA +="#"+reader4["ServId"];
Servicios.Text+="<br>";
}

y en el codigo html:

<td headers="usuarios servicios"><asp:label id="Servicios" runat="server"></asp:label>
<input type="text" id="text" value=<%= VARIABLEPUBLICA %>></td>

Por donde tiro ahora????
  #51 (permalink)  
Antiguo 11/05/2005, 01:35
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Pues para el insert, habría que recorrer el array de nuevo y por cada Id del servicio, que no esté ya en la BD deberíamos hacer un insert.

Para ello, podríamos meter la Variablepublica en el viewstate,
if (reader4["UsServIdUs"].ToString()=="")
{
...
}
else
{
...
VARIABLEPUBLICA+="#"+reader4["ServId"];
System.ViewState["identificadores"] = VARIABLEPUBLICA
}


y luego en tu botón actualizar, tras todo lo anterior.

i=0;
while (i< arr.length)
{
if (Convert.toString(System.ViewState["identificadores"]).Contains(arr[i]).toString)
{
'No hacemos nada puesto que ya está insertado
}
else
{
mycommand.commandtext = "Insert into UsuariosServicios ...."
}
i+=1;
}


Luego, lo que dices del split, es cosa de la sintaxis de c#, hay ya no te puedo ayudar
  #52 (permalink)  
Antiguo 11/05/2005, 01:58
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
Hemos avanzado :)

Mira la cosa keda asi:

en en onload:
if (Request.Form["__eventtarget"].ToString() == "guardar")
{
string identificadores = Request.Form["__eventargument"];
Array arrayidentificadores = (identificadores.Split(Convert.ToChar("#")));
CambiaServicios(arrayidentificadores);
}

la funcion cambia servicios:

private void CambiaServicios(Array arr)
{
myConnection = new SqlConnection (connectionString);
string updateCmd;

if (ConfUsPass.Visible)
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsPass=@UsPass,UsMail=@UsMail,U sTelefono=@UsTelefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
else
{
updateCmd = "UPDATE Usuarios SET UsNombre=@UsNombre,UsMail=@UsMail,UsTelefono=@UsTe lefono,UsIdPer=@UsIdPer where UsId=@UsId";
}
myCommand = new SqlCommand(updateCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@UsId",
SqlDbType.Int, 4));
myCommand.Parameters["@UsId"].Value = ComboLogin.SelectedItem.Value;
myCommand.Parameters.Add(new SqlParameter("@UsNombre",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsNombre"].Value = UsNombre.Value;
myCommand.Parameters.Add(new SqlParameter("@UsPass",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsPass"].Value = UsPass.Value;
myCommand.Parameters.Add(new SqlParameter("@UsMail",
SqlDbType.NVarChar, 50));
myCommand.Parameters["@UsMail"].Value = UsMail.Value;
myCommand.Parameters.Add(new SqlParameter("@UsTelefono",
SqlDbType.NVarChar, 15));
myCommand.Parameters["@UsTelefono"].Value = UsTelefono.Value;
myCommand.Parameters.Add(new SqlParameter("@UsIdPer",
SqlDbType.Int, 4));
myCommand.Parameters["@UsIdPer"].Value = UsPerfil.SelectedItem.Value;
myCommand.Connection.Open();
try
{
if ((ConfUsPass.Visible) && (UsPass.Value!=ConfUsPass.Value))
MsgBox1.alert("El password no es correcto");
else
{
int numreg=myCommand.ExecuteNonQuery();
//updateservicios();
Response.Redirect("MenuadministradorUsu.aspx?Oku=1 &Nombre="+Request.QueryString["Nombre"].ToString()+"&Id="+Request.QueryString["id"].ToString()+"&mod="+ComboLogin.SelectedItem.Value) ;
//Response.Redirect("Menuadministrador1.aspx?Oku=1&m od="+nombre.Text);
}
}
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();

string sql;
int i=0;
while (i< arr.Length)
{
if (i==0)
sql = " where UsServIdServ==" & arr[i];
else
sql += " and UsServIdServ==" & arr[i];
i+=1;
}
sql = "Delete from UsuariosServicios " + sql + " and UsServIdUs=" + ComboLogin.SelectedItem.Value;
myCommand.Connection.Open();
myCommand.CommandText = sql;
myCommand.Connection.Close();
i=0;
while (i< arr.Length)
{
if (Convert.toString(System.ViewState["identificadores"]).Contains(arr[i]).toString)
{

}
else
{
myCommand.CommandText = " Insert into UsuariosServicios (UsServIdServ,UsServIdUs) values(" & arr[i] &"," & ComboLogin.SelectedItem.Value &")";
}
i+=1;
}
myCommand.Connection.Open();
myCommand.Connection.Close();
}
te parece correcto lo del insert y el update???

Muchas gracias por todo esto, sin tu ayuda la cosa estaria muuuuy jodida...
  #53 (permalink)  
Antiguo 11/05/2005, 02:14
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
De momento parece que todo está correcto, si el nuestro input de apoyo invisible coge los valores correctamente de los checkbox y les pone # y en caso contrario los quita, quitando #, todo debería funcionar bien (aunque seguro que hay algún fallo de última hora, jeje), pruebalo haber que tal
  #54 (permalink)  
Antiguo 11/05/2005, 02:17
Avatar de neivan  
Fecha de Ingreso: febrero-2005
Mensajes: 539
Antigüedad: 20 años
Puntos: 1
yo en principio puse el input invisible visible para ver si iba cogiendo los datos bien... por si tienes un fallo saber donde casca.... suerte
  #55 (permalink)  
Antiguo 11/05/2005, 03:11
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
primer casque

Me dice:
Object reference not set to an instance of an object.

Y me lo da en esta linea:

if (Request.Form["__eventtarget"].ToString() == "Guardar")
{

Mirar mi linea del dopostback:

<A class="botones actualizar" runat="server" onclick="__doPostBack('Guardar',document.getElemen tById('text').value);" href="#">Actualizar</A>

Alguna ocurrencia????
  #56 (permalink)  
Antiguo 11/05/2005, 03:18
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Viendo el input en visible, has visto si tienes bien los datos??Es decir, si tiene algún valor????

También debes asegurarte de que esté dentro de postback en el page_load, es decir, además, yo lo pondría con un convert.tostring

If (IsPostBack)
{
If Convert.toString(Request.Form["__eventtarget"])=="Guardar"
{
....
}
}
  #57 (permalink)  
Antiguo 11/05/2005, 03:43
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
me da error esto

esto me da error:

Array []arrayidentificadores = (identificadores.Split(Convert.ToChar("#")));
Hay alguna forma de hacerlo sin Split es que me dice:
No se puede convertir de tipo string[] a system.array[]
  #58 (permalink)  
Antiguo 11/05/2005, 03:47
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
Hazlo así:

String [] arrayidentificadores = identificadores.Split(Convert.ToChar("#"));

o si no

Char [] arrayid....
  #59 (permalink)  
Antiguo 11/05/2005, 03:58
Avatar de Nombela  
Fecha de Ingreso: abril-2005
Mensajes: 611
Antigüedad: 19 años, 10 meses
Puntos: 1
ultimo errorcillo (por ahora)

Mira tengo este problema:

if ((ViewState["identificadores"]).ToString().contains(arr[i]).ToString())

Me dice que no contiene una definicion para contains.
  #60 (permalink)  
Antiguo 11/05/2005, 04:15
Avatar de Jose_minglein2  
Fecha de Ingreso: noviembre-2004
Mensajes: 2.344
Antigüedad: 20 años, 3 meses
Puntos: 8
if (Convert.ToString(ViewState["identificadores"]).IndexOf(arr[Convert.ToInt16(i)]) !=-1)
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 12:55.