how to add new rows into a datatable vb.net

Here is an example of adding a new row to a datatable that uses AutoIncrement on the first column:

Define the table structure:

    Dim dt As New DataTable
    dt.Columns.Add("ID")
    dt.Columns.Add("Name")
    dt.Columns(0).AutoIncrement = True

Add a New row:

    Dim R As DataRow = dt.NewRow
    R("Name") = txtName.Text
    dt.Rows.Add(R)
    DataGridView1.DataSource = dt

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)