Question Add Another Row to DataGridView

otester

New member
Joined
Nov 22, 2010
Messages
4
Programming Experience
1-3
I've made an add button and I want it to add another row to the DGV and fill it with data from a database query.

Add button code:

VB.NET:
Me.DataSet.App.Rows.Add() 'this does add a new empty row

Code for filling the DGV with a query:

VB.NET:
Try
   Me.English_AppTableAdapter.FillBy1(Me.PunchDataSet.English_App)
Catch ex As System.Exception
   System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

Is there any way to do this?


Any help would be greatly appreciated!

Thanks,

otester
 
I wanted to add a row that pulled data from the database (without removing the others), not just text like the link had.
 
Hi Otester,

If u want to insert data from the dataset into each column on the DGV, i think u should do something like below:

With DGV
.rows.add
.rows(0).cell(0).value = Me.PunchDataSet.tables("English_App").rows(0).item("Columname")
.rows(0).cell(1).value = Me.PunchDataSet.tables("English_App").rows(0).item("Columname")
'add more if u have more colum
End With

if u have more than 1 row to add, u should loop them
 
English_AppTableAdapter has a ClearBeforeFill property that is True by default, set it to False to have the Fill append results to existing table.
 
Back
Top