Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
add 20 rows below the 1 column using vb.net and then all these data add in access database can any help for this.
Posted
Updated 4-May-12 17:41pm
v2

1 solution

Hi,

Is your grid bound to a data source? If so then you should be adding and deleting rows in that data source, not the grid. If the grid is unbound then you call the Add and Remove methods of the grid's Rows collection.

Adding a row to datagridview with textBox columns

VB
Dim dgvRow As New DataGridViewRow
Dim dgvCell As DataGridViewCell

dgvCell = New DataGridViewTextBoxCell()
dgvCell.Value = "anis"
dgvRow.Cells.Add(dgvCell)

dgvCell = New DataGridViewTextBoxCell()
dgvCell.Value = "khan"
dgvRow.Cells.Add(dgvCell)

DataGridView1.Rows.Add(dgvRow)


and to add multiple rows in access try like following
VB
Dim rsTemp     As DAO.Recordset
Dim i          As Integer

    'Create a copy of this forms Recordset

    Set rsTemp = Me.RecordsetClone

    rsTemp.MoveFirst

    'Loop through all records and Add new record..

    For i = 1 To rsTemp.RecordCount

        If Me.CurrentRecord = True Then
            CurrentDb.Execute INSERT INTO table (column-1, column-2, ... column-n) VALUES (value-1, value-2, ... value-n);
        End If

        rsTemp.MoveNext

    Next i

    'Release resources

    rsTemp.Close

    Set rsTemp = Nothing


Best Luck
Happy Coding:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900