Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/09/2011, 08:42
Korreca
 
Fecha de Ingreso: junio-2010
Mensajes: 49
Antigüedad: 14 años
Puntos: 2
Respuesta: actualizar varios textbox al mismo tiempo

Lo primero, mejor utilizar arrais que declarar tanta variable terminada en número, mas limpio todo.

Lo segundo, cada vez que haces "myCommand = New SqlCommand(cadtexto, myConnection)" estás haciendo un nuevo comando, con lo cual los que hiciste antes se descartan, solo te vale el último.

Prueba con esto:

myConnection = New SqlConnection("Data Source=DELLMR;Initial Catalog=Compras;Persist Security Info=True;User ID=sa;Password=Stm01;Connect Timeout=200 ")
myCommand = New SqlCommand
myCommand.Connection = myConnection
Dim txt(4) as string = {Trim(TextBox3.text), Trim(TextBox4.text), Trim(TextBox5.text), Trim(TextBox6.text), Trim(TextBox7.text)}
myConnection.Open()
for i = 0 to txt.GetUpperBound(0)
myCommand.CommandText = "Update ocfiltro Set Agencia = ' " + DropDownList1.Text + " ' ,Paquete = ' " + TextBox2.Text + " ' where oc ='" & txt(i) & " ' "
myCommand.ExecuteNonQuery()
next
myConnection.Close()