Hi, it's me again,
Well now, being born again in the field of programming, I still have trouble.
Now, on my application, I created a datagridview and I linked to a Access database, but when I fill the datagridview and I click on "Save", only the first line is recorded on the table and not the other.
Here's the code:
Thank you kindly help me to record the entire table and be able to add more lines.
thank you
Well now, being born again in the field of programming, I still have trouble.
Now, on my application, I created a datagridview and I linked to a Access database, but when I fill the datagridview and I click on "Save", only the first line is recorded on the table and not the other.
Here's the code:
Using cmd As New OleDb.OleDbCommand("insert into " & TextBox1.Text & "CC (Immatriculation, NDuBon, CodeChauffeur, Date1, Heure1, LieuApprovisionnement, Kilometrage, Quantite, Total) VALUES (@Immatriculation, @NDuBon, @CodeChauffeur, @Date1, @Heure1, @LieuApprovisionnement, @Kilometrage, @Quantite, @Total)", conn) For i = 2 To (Me.DataGridView1.RowCount - 1) cmd.Parameters.Add("@Immatriculation", OleDbType.VarChar).Value = IIf(Len(Trim(Me.TextBox1.Text())) > 0, Me.TextBox1.Text(), Label133.Text) cmd.Parameters.Add("@NDuBon", OleDbType.VarChar).Value = Me.DataGridView1.Rows(i).Cells(0).Value cmd.Parameters.Add("@CodeChauffeur", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(1).Value())) > 0, Me.DataGridView1.Rows(i).Cells(1).Value(), Label133.Text) cmd.Parameters.Add("@Date1", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(2).Value())) > 0, Me.DataGridView1.Rows(i).Cells(2).Value(), Label133.Text) cmd.Parameters.Add("@Heure1", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(3).Value())) > 0, Me.DataGridView1.Rows(i).Cells(3).Value(), Label133.Text) cmd.Parameters.Add("@LieuApprovisionnement", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(4).Value())) > 0, Me.DataGridView1.Rows(i).Cells(4).Value(), Label133.Text) cmd.Parameters.Add("@Kilometrage", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(5).Value())) > 0, Me.DataGridView1.Rows(i).Cells(5).Value(), Label133.Text) cmd.Parameters.Add("@Quantite", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(6).Value())) > 0, Me.DataGridView1.Rows(i).Cells(6).Value(), Label133.Text) cmd.Parameters.Add("@Total", OleDbType.VarChar).Value = IIf(Len(Trim(Me.DataGridView1.Rows(i).Cells(7).Value())) > 0, Me.DataGridView1.Rows(i).Cells(7).Value(), Label133.Text) Next Try cmd.ExecuteNonQuery() Catch ex As Exception MsgBox(ErrorToString) End Try End Using
Thank you kindly help me to record the entire table and be able to add more lines.
thank you
Last edited by a moderator: