This is a migrated thread and some comments may be shown as answers.

save all radgrid

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 2
Robert asked on 29 Dec 2011, 03:43 PM
hi everyone, i am trying to learn more about .net and teleriks control i have an easy problem but for my inexperience in this i could not to resolve, i need to save all data of my radgrid in other table, but i dont know why only save one row when i have for example 3 rows, it save only the first one i print for example the name of the product and show me 3 products so is correct the problem is when i have to save... :( .... this is my code i hope u can help me :(


Dim Connstring As String = "something"
        Dim Conn As SqlConnection = New SqlConnection(Connstring)
        Dim cmd As New SqlCommand
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "auxiliar_compra"
        cmd.Connection = Conn
        For Each dataItem As GridDataItem In RadGrid1.Items

            Try
                MsgBox(dataItem("producto").Text)
                cmd.Parameters.Add("@param1", SqlDbType.Int).Value = dataItem("cod_provee").Text
                cmd.Parameters.Add("@param2", SqlDbType.Char).Value = dataItem("proveedor").Text
                cmd.Parameters.Add("@param3", SqlDbType.Char).Value = dataItem("codigo").Text
                cmd.Parameters.Add("@param4", SqlDbType.Char).Value = dataItem("producto").Text
                cmd.Parameters.Add("@param5", SqlDbType.Decimal).Value = dataItem("unidades").Text
                cmd.Parameters.Add("@param6", SqlDbType.Money).Value = dataItem("precio").Text
                cmd.Parameters.Add("@param7", SqlDbType.Decimal).Value = dataItem("porcomprar").Text       
                cmd.Connection.Open()
                cmd.ExecuteNonQuery()
               cmd.Parameters.Clear()
            Catch ex As Exception

            End Try

        Next
cmd.Connection.Close()

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 2
answered on 29 Dec 2011, 04:13 PM
thanks i resolved it :S the problem was than i was open the connection inside of the for each, i put it out and its work :)
Tags
Grid
Asked by
Robert
Top achievements
Rank 2
Answers by
Robert
Top achievements
Rank 2
Share this question
or