Dear All Master, please help me for my first program that i want to create...i have problem for save from datagridview to access database...everytime i try to save , only first line have save...another not save...sory for my bad english language...thank's
here my code....
Sub simpen()
Dim i As Integer
Dim cmd As New OleDbCommand
cmd.Connection = con
For i = 0 To DataGridView1.Rows.Count - 1
strsql = "insert into students_grade (student_no, student_name, grade) values (@student_no, @student_name, @grade)"
cmd.CommandText = strsql
With cmd.Parameters
cmd.Parameters.AddWithValue("@student_no", DataGridView1.Rows(i).Cells(0).Value)
cmd.Parameters.AddWithValue("@student_name", DataGridView1.Rows(i).Cells(1).Value)
cmd.Parameters.AddWithValue("@grade", DataGridView1.Rows(i).Cells(2).Value)
End With
acsdr = cmd.ExecuteReader
acsdr.Close()
Next i
MessageBox.Show("Data Inserted")
End Sub