Is there possiblity to send, 5 data(5rows) at one time to the sql database in vb.net2008

Recommended Answers

Yes. Just adjust your insert query.

... VALUES (1, 'a'), (2, 'b'), (3, 'c')
Jump to Post

All 2 Replies

Yes. Just adjust your insert query.

... VALUES (1, 'a'), (2, 'b'), (3, 'c')

Let me know whereto adjust.................

 Dim comd As SqlCommand = myConnection.CreateCommand()
            myConnection = New SqlConnection(connectionstring)
            comd.Connection = myConnection
            comd.CommandText = "Insert into NEW1([Fruits] ,[Countries]) values( @Fruits   ,@Countries)"

            'Adding Parameters
            comd.Parameters.Add("@Fruits", SqlDbType.VarChar, 250)
            comd.Parameters.Add("@Countries", SqlDbType.NVarChar, 250)
            'comd.Parameters.Add("@Qty", SqlDbType.VarChar, 50)
            'comd.Parameters.Add("@Rte", SqlDbType.VarChar, 50)
            'comd.Parameters.Add("@TotalAmt", SqlDbType.VarChar, 50)

            'Data Inserted

            For Each row As DataGridViewRow In DataGridView1.Rows
                If Not row.IsNewRow Then
                    comd.Parameters("@Fruits").Value = row.Cells(0).Value.ToString
                    comd.Parameters("@Countries").Value = row.Cells(1).Value.ToString
                    '    comd.Parameters("@Qty").Value = row.Cells(2).ToString
                    '    comd.Parameters("@Rte").Value = row.Cells(3).ToString
                    '    comd.Parameters("@TotalAmt").Value = row.Cells(4).ToString
                End If
            MessageBox.Show("Data Inserted")

        Catch ex As Exception
            MessageBox.Show("Error :" & ex.ToString())
        End Try
        'MessageBox.Show("Enter PoNumber")
        'End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.