Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim cmd As New OleDbCommand() With {.Connection = conn} Dim sql As String Dim result As Integer conn.Open() For Each row As DataGridViewRow In DataGridView1.Rows sql = "INSERT INTO Table3 (matricule,ref_cour,exam) VALUES ('" _ & CStr(row.Cells(0).Value) & "','" _ & CStr(row.Cells(5).Value) & "','" _ & CStr(row.Cells(7).Value) & "')" With cmd .Connection = conn .CommandText = sql End With result = cmd.ExecuteNonQuery Next If result = 0 Then MsgBox("No saved Record.") Else MsgBox("All Records Saved.") End If Catch ex As Exception MsgBox(ex.Message) End Try conn.Close() End Sub![]()
Partager