I have created a datagridview on a vb.nt form with drug_id,brand_name,date_made,date_expired as columns and i want to get a vb.net procedure or vb.net code that will insert the data on the datagridview to my Access database when i click insert button on the form.My database contains int_id column which is autoincremental and my datagridview contains several rows.Thanks for anticipated help.

4 Years
Discussion Span
Last Post by kRod

Hope this gets you started, it creates the insert query "q". You will need a connection and a command object.... You should read up on Datasets - Datatables - Datagridview - MS ACCESS. There are much easier ways of doing what you want. Please show what you have tried.

For r = 0 To DataGridView1.Rows.Count - 1
    q = "insert into data values('" & DataGridView1.Rows.Cells(0).Value & " ', ' " & DataGridView1.Rows.Cells(1).Value & "')"

Edited by kRod


how can I insert data from a textbox viewed to datagridview and save to database in vb.net?


vanbane27 you need to start a new thread. I will also say that you need to provide a little more info about what you are trying to accomplish and show what you have tried.

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.