In this article i will describe how to insert record into database from Listview control using C#.Net.
In the Previous articles i explained how to delete record from access database using vb.net, how to add namespace in vb.net, redirect to page according to role while login in asp.net, how to open form on click of the button using c#.net, how to close form on click of the button using C#.net and many more about C#.Net.
Drag and Drop a button and Listview control on Form.
Write the following code on click event of the Button.
foreach (ListViewItem li in listView1.Items)
OleDbCommand cmd = new OleDbCommand("insert into bookings (code,client_name)values('" + li.SubItems.Text + "','" + li.SubItems.Text + "');", con);
Here i am inserting data into bookings table from Listview. Here foreach loop will run till the last row of list view control.