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.