I have a datagridview which contains 4 records.
I want to insert these records into access table.This access table already have records.
Datagridview's columns & access table's columns are same (datatype & columnname)
How can i insert these 4 records in access table???
Plz anybody help me..............

Thanks in advance...

It should be something along the lines of this:

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\NorthWind.mdb"
Dim dbConnection As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

For Each DR In DS.Tables(0).Rows
    Dim queryString As String = "INSERT INTO table_name (Field1, Field2, Field3, Field4) VALUES ('" & DR.Item(0) & "', '" & DR.Item(1) & "', '" & DR.Item(2) & "', '" & DR.Item(3) & "')"
    Dim dbCommand As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(queryString, dbConnection)    

dbConnection .Close()

You might have to make some adjustments to suite your needs, but I think the idea is more or less to:

  1. Open a connection to your access database
  2. Loop through the grid's rows and inserting them one by one
  3. Closing the connection

Edited 6 Years Ago by Some-Jackass: n/a

Thank you Jackass.It's working.Thank u so much.

Can you plz tell me how to handle datagridviewcombox's event.
I have a datagrid which contains 3 combobox.
I want ,When i clicked 1st combo data should be filtered in 2nd combo.
Is it possoble in datagrid????
I think u can answer my question.
Plz help me.........

This question has already been answered. Start a new discussion instead.