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

vaciar matriz

Estas en el tema de vaciar matriz en el foro de .NET en Foros del Web. hola tengo dos botones agregar y guardar agregar: If (matriz(i, 0) Is Nothing) Then matriz(i, 0) = TextBox17.Text 'codigo epp matriz(i, 1) = TextBox9.Text 'descripcion ...
  #1 (permalink)  
Antiguo 15/10/2007, 10:46
Avatar de mamicho  
Fecha de Ingreso: mayo-2007
Mensajes: 98
Antigüedad: 17 años
Puntos: 0
Pregunta vaciar matriz

hola tengo dos botones agregar y guardar

agregar:

If (matriz(i, 0) Is Nothing) Then


matriz(i, 0) = TextBox17.Text 'codigo epp

matriz(i, 1) = TextBox9.Text 'descripcion

matriz(i, 2) = TextBox11.Text 'talla

matriz(i, 3) = TextBox12.Text 'color

matriz(i, 4) = TextBox13.Text 'cantidad


TextBox17.Text = ""
TextBox11.Text = ""
TextBox9.Text = ""
TextBox13.Text = ""
TextBox12.Text = ""
i = i + 1


End If


guardar:

cn.ConnectionString = "Data Source=MAURY;Initial Catalog=equipos;Integrated Security=True;"


cmd = New SqlCommand
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spAgregaDetalle"
cmd.Connection = cn
Dim da As New SqlDataAdapter
da.InsertCommand = cmd

Dim dsol_numero_solicitud As New SqlParameter("@dsol_numero_solicitud", SqlDbType.VarChar, 50)
Dim dsol_epp As New SqlParameter("@dsol_epp", SqlDbType.VarChar, 50)
Dim dsol_talla As New SqlParameter("@dsol_talla", SqlDbType.VarChar, 50)
Dim dsol_color As New SqlParameter("@dsol_color", SqlDbType.VarChar, 50)
Dim dsol_cantidad As New SqlParameter("@dsol_cantidad", SqlDbType.VarChar, 50)
Dim dsol_estado As New SqlParameter("@dsol_estado", SqlDbType.VarChar, 50)

da.InsertCommand.Parameters.Add(dsol_numero_solici tud)
da.InsertCommand.Parameters.Add(dsol_epp)
da.InsertCommand.Parameters.Add(dsol_talla)

da.InsertCommand.Parameters.Add(dsol_color)
da.InsertCommand.Parameters.Add(dsol_cantidad)
da.InsertCommand.Parameters.Add(dsol_estado)

Try
Using cn


cn.Open()


For contador As Integer = 0 To 99
If (Not (matriz(contador, 0) Is Nothing)) Then


da.InsertCommand.Parameters(0).Value = 1

da.InsertCommand.Parameters(1).Value = matriz(contador, 0)

da.InsertCommand.Parameters(2).Value = matriz(contador, 2)


da.InsertCommand.Parameters(3).Value = matriz(contador, 3)

da.InsertCommand.Parameters(4).Value = matriz(contador, 4)

da.InsertCommand.Parameters(5).Value = 1

da.InsertCommand.ExecuteNonQuery()

Else

Exit For

End If
Next


End Using

Catch ex As Exception
MsgBox(ex.Message)
End Try


ahora lo que pasa es que cuando agrego por segunda ves me agrega los datos de la primera ves igual y nose como se puede arreglar eso.
  #2 (permalink)  
Antiguo 15/10/2007, 10:48
Avatar de mamicho  
Fecha de Ingreso: mayo-2007
Mensajes: 98
Antigüedad: 17 años
Puntos: 0
Re: vaciar matriz

perdon cuando guardo por segunda vez.
  #3 (permalink)  
Antiguo 16/10/2007, 05:18
 
Fecha de Ingreso: septiembre-2007
Mensajes: 68
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: vaciar matriz

creo q deberias limpiar la matriz una vez que has guardado el elemento
  #4 (permalink)  
Antiguo 16/10/2007, 14:20
Avatar de mamicho  
Fecha de Ingreso: mayo-2007
Mensajes: 98
Antigüedad: 17 años
Puntos: 0
Re: vaciar matriz

algo asi matriz(i,0) = nothing????
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 18:20.