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

matrizes asp.net

Estas en el tema de matrizes asp.net en el foro de .NET en Foros del Web. hola, tengo 6 textbox y dos botones "agregar" "grabar" al agregar datos en los text y pulsar el boton agregar me los tiene que guardar ...
  #1 (permalink)  
Antiguo 06/10/2007, 17:03
Avatar de mamicho  
Fecha de Ingreso: mayo-2007
Mensajes: 98
Antigüedad: 17 años
Puntos: 0
De acuerdo matrizes asp.net

hola, tengo 6 textbox y dos botones "agregar" "grabar"

al agregar datos en los text y pulsar el boton agregar me los tiene que guardar en una matriz las veces que se aprete el boton guardar,
pero cuando aprete el boton "grabar" tiene que mandar los datos de la matriz a la tabla de la bdd.

asi declare:

Public matriz(100, 6) As String
Public i As Integer


boton agregar:

i = i + 1
matriz(i, 0) = TextBox11.Text
matriz(i, 1) = TextBox12.Text
matriz(i, 2) = TextBox13.Text
matriz(i, 3) = TextBox14.Text
matriz(i, 4) = TextBox15.Text
matriz(i, 5) = TextBox16.Text


boton grabar "que llama al procedimiento spAgregaDetalle":

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)



Try

For i = 1 To UBound(matriz)
Using cn


da.InsertCommand.Parameters.Add(dsol_numero_solici tud)
da.InsertCommand.Parameters(0).Value = matriz(i, 0)
da.InsertCommand.Parameters.Add(dsol_epp)
da.InsertCommand.Parameters(1).Value = matriz(i, 1)
da.InsertCommand.Parameters.Add(dsol_talla)
da.InsertCommand.Parameters(2).Value = matriz(i, 2)

da.InsertCommand.Parameters.Add(dsol_color)
da.InsertCommand.Parameters(3).Value = matriz(i, 3)
da.InsertCommand.Parameters.Add(dsol_cantidad)
da.InsertCommand.Parameters(4).Value = matriz(i, 4)
da.InsertCommand.Parameters.Add(dsol_estado)
da.InsertCommand.Parameters(5).Value = matriz(i, 5)

cn.Open()
da.InsertCommand.ExecuteNonQuery()

da.Dispose()
cmd.Dispose()
End Using

Next


Catch ex As Exception

End Try


pero nose que falla porque no graba
  #2 (permalink)  
Antiguo 08/10/2007, 11:20
Avatar de mamicho  
Fecha de Ingreso: mayo-2007
Mensajes: 98
Antigüedad: 17 años
Puntos: 0
Re: matrizes asp.net

estuve depurando y me di cuenta que perdia la matriz despues de apretar el boton agregar por eso alomejor no graba despues,
nose porque la pierdo si arriba la declare :
Public matriz(100, 6) As String
Public i As Integer
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:25.