добавление данных в цикле из datagridview

Язык Visual Basic на платформе .NET.

Модераторы: Ramzes, Sebas

Anta
Продвинутый пользователь
Продвинутый пользователь
 
Сообщения: 106
Зарегистрирован: 19.08.2012 (Вс) 22:00

добавление данных в цикле из datagridview

Сообщение Anta » 18.03.2013 (Пн) 19:24

здравствуйте , выполняю insert( с помощью executenonquery) в таблицу oracle в цикле из datagridview, использую параметры.
первая строка проходит, следующая нет, сообщение-неправильный параметр, как работать с параметрами в цикле?
Код: Выделить всё
  b = DgvMutation.Rows.Count

             For c = 0 To b - 1   
         
            ordre_tache = CInt(DgvMutation.Rows.Item(c).Cells(0).Value)
            no_inscription = DgvMutation.Rows.Item(c).Cells(1).Value
            mat10_origine = DgvMutation.Rows.Item(c).Cells(2).Value

            lotResiduel = DgvMutation.Rows.Item(c).Cells(3).Value
            ActionLotResiduel = DgvMutation.Rows.Item(c).Cells(4).Value

            lotTransf = DgvMutation.Rows.Item(c).Cells(5).Value
            ActionLotTransferes = DgvMutation.Rows.Item(c).Cells(6).Value

            UEVTransfer = DgvMutation.Rows.Item(c).Cells(7).Value



            sql = "insert into table(FID, NO_INSCRIPTION, ORDRE_TACHE, MAT10_ORIGINE, ACTION_LOT_RESIDUEL, ACTION_LOT_TRANS, MAT10_TRANSFERT) VALUES LBPA_SEQ_MUT_TACHE.nextval, '" + no_inscription.ToString + "', ?, '" + mat10_origine + "', ?, ?, '" + UEVTransfer + "')"

            ' commandeInsert2.Transaction = TransactionInsert
            With commandeInsert2
                .Connection = ObjConn
                .CommandType = CommandType.Text
                .CommandText = sql
            End With

            Dim prmOrdre_tache1 As OleDbParameter = commandeInsert2.Parameters.Add("@ordre_tache", OleDbType.Integer)
            prmOrdre_tache1.Value = CInt(ordre_tache)

            Dim prmActionResidu As OleDbParameter = commandeInsert2.Parameters.Add("@ACTION_LOT_RESIDUEL", OleDbType.Char)
            prmActionResidu.Value = ActionLotResiduel

            Dim prmActionTR As OleDbParameter = commandeInsert2.Parameters.Add("@ACTION_LOT_TRANS", OleDbType.Char)
            prmActionTR.Value = ActionLotTransferes
            commandeInsert2.ExecuteNonQuery()
------------------------------
         
            With commandeInsert3
                .Connection = ObjConn
                .CommandType = CommandType.Text
                .CommandText = "insert into " + Ville.ToString + ".LBPA_MUTATION_LOT_RESIDUEL (FID, NO_INSCRIPTION, ORDRE_TACHE, NUM_LOT)  VALUES (" + Ville + ".LBPA_SEQ_LOT_RESID.nextval, '" + no_inscription + "', ?, '" + lotResiduel + "' )"
            End With


            Dim prmOrdre_tache2 As OleDbParameter = commandeInsert3.Parameters.Add("@ordre_tache", OleDbType.Integer)
            prmOrdre_tache2.Value = CInt(ordre_tache)
            commandeInsert3.ExecuteNonQuery()


          ---------------
            With commandeInsert4
                .Connection = ObjConn
                .CommandType = CommandType.Text
                .CommandText = "insert into " + Ville + ".LBPA_MUTATION_LOT_TRANS (FID, NO_INSCRIPTION, ORDRE_TACHE, NUM_LOT)  VALUES ("LBPA_SEQ_LOT_trans.nextval, '" + no_inscription + "', ?, '" + lotTransferes + "' )"
            End With



            Dim prmOrdre_tache3 As OleDbParameter = commandeInsert4.Parameters.Add("@ordre_tache", OleDbType.Integer)
            prmOrdre_tache3.Value = CInt(ordre_tache)
            commandeInsert4.ExecuteNonQuery()

        Next

               Try
            ObjConn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Message d'alerte", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

Anta
Продвинутый пользователь
Продвинутый пользователь
 
Сообщения: 106
Зарегистрирован: 19.08.2012 (Вс) 22:00

Re: добавление данных в цикле из datagridview

Сообщение Anta » 20.03.2013 (Ср) 1:33

ни у кого нет идей? спасибо

Anta
Продвинутый пользователь
Продвинутый пользователь
 
Сообщения: 106
Зарегистрирован: 19.08.2012 (Вс) 22:00

Re: добавление данных в цикле из datagridview

Сообщение Anta » 21.03.2013 (Чт) 2:45

вопрос решен, сбросом параметров.


Вернуться в Visual Basic .NET

Кто сейчас на конференции

Сейчас этот форум просматривают: Google-бот, SemrushBot и гости: 9

    TopList