I'm working with my project and i want to save all the records in my datagridview in one id but the resultt, only one row inserted in my database
table picture as you can see, there are two rows, but when I click submit only one row will save to my database.
This is my code in submit button
Dim p_id As Integer
Dim p_description As String = Nothing
Dim p_from As String = Nothing
Dim p_to As String = Nothing
Dim table As New DataTable
For i As Integer = 0 To DataGridView2.Rows.Count = 1
p_id = DataGridView2.Rows(i).Cells(0).Value
p_description = DataGridView2.Rows(i).Cells(1).Value
p_from = DataGridView2.Rows(i).Cells(2).Value
p_to = DataGridView2.Rows(i).Cells(3).Value
Next
'sql insert query'
sql_query = sql_query = "INSERT INTO Petition_tbl(p_id,p_name_of_petitioner,p_item_no,p_description,p_from,p_to)VALUES('"petition_id.Text.Trim"''" & petitioner_name.Text.Trim & "','" & p_id & "','" & p_description & "','" & p_from & "','" & p_to & "')"
Anyone can help me, will be appreciated.