【问题标题】:How to add multiple records in SQL Server using DataGridView如何使用 DataGridView 在 SQL Server 中添加多条记录
【发布时间】:2016-03-07 10:31:37
【问题描述】:

我正在将 VB.Net 与 SQL Server 一起使用,并且正在尝试将在 DataGridView 中修改的值集成到 SQL Server 数据库中。我们将不胜感激有关如何进行此操作的一些指导。

【问题讨论】:

  • 请添加您目前编写的代码。
  • 我只想知道实现这种治疗的方法
  • 看看这个问题:Save Datagrid data to SQL Server database in VB.Net。您可能会发现它是一份有用的指南。
  • Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged If sql.connect = True Then Dim i As New Integer While (i

标签: sql-server vb.net


【解决方案1】:

有代码

Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        If sql.connect = True Then
            Dim i As New Integer

            While (i < DataGridView1.RowCount)


                sql.exereq("update avance set montant='" & DataGridView1.Rows(i).Cells(3).Value & "' where  IdFuncionario='" & DataGridView1.Rows(i).Cells(0).Value & "'")
                i += 1
            End While
        End If
    End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多