0

Hi,
I am using VB.Net 2005, VS 2005, and an Access Database.
I have a datagridview on a form that gets populated from a table in the Access DB. What I'm needing to do is take the data from the DGV and put it into a table, "not the original table," in the Access DB. I've tried many things that haven't worked. What should I be trying?

Thanks,
Dave

2
Contributors
2
Replies
8
Views
9 Years
Discussion Span
Last Post by himanshu.tomar
0

Here's the code I use to fill the datagridview. I think the data is stored in the datatable, so I am trying to find a way to take it from there and put it in a table in my Access DB.

Public Class frmWaves
    Private mAdapter As New OleDb.OleDbDataAdapter()
    Private wAdapter As New OleDb.OleDbDataAdapter()
    Private m_Dataset As DataSet
    Private ds As New DataSet()
    Private connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source='I:\Wave_Selection\Wave Selection\Wave_Selection_1.0\Wave_Selection_1.0\Wave_Selection.mdb';Persist Security Info=False"
Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click
        'Load DataGridView

        mAdapter.SelectCommand = _
            New OleDb.OleDbCommand(SQL1, New OleDb.OleDbConnection(connectionString))
        'Auto-Generate INSERT, UPDATE and DELETE sql commands
        Dim cb As New OleDb.OleDbCommandBuilder(mAdapter)
        mAdapter.AcceptChangesDuringFill = False
        'Fill table
        Dim table As New DataTable()
        mAdapter.Fill(table)

        'Set as DataSource for grid
        Me.dgResults.DataSource = table
        Me.dgResults.AutoResizeColumns( _
           DataGridViewAutoSizeColumnsMode.AllCells)
    End Sub
0

Hello Dave,
For your problem you can simply write the insert query for that demo table in the database by using the following code::

dim dgr1 as DataGridViewRow

for each dgr1 in me.dgvName.rows
insert into demo_table(" _
"'" & (values)&"'")
next

This will help you.
Himanshu

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.