I was trying this code to insert the items from ListView to Ms Access Table, and It works well with me. How can I insert the item from DataGridView to Ms Access?
I start by this code but I didn't know how to complete
VB.NET:
[COLOR=#000099][FONT=Courier New][COLOR=black]For i = 0 To Form1.ListView1.Items.Count - 1[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]cmd.CommandText = "INSERT INTO TBbills (BMaterial,BKind)[SIZE=2][COLOR=#800000]
[COLOR=black]VALUES (@Material,@BKind)[/COLOR]
[/COLOR][/SIZE][/COLOR][/FONT][FONT=Courier New][COLOR=black]cmd.Parameters.AddWithValue("BMaterial", Form1.ListView1.Items(i).SubItems(11).Text)[/COLOR][/FONT]
[FONT=Courier New][COLOR=#7f5f00][COLOR=#7f5f00][FONT=Courier New][COLOR=black]cmd.Parameters.AddWithValue("@BKind", Form1.ListView1.Items(i).SubItems(10).Text)[/COLOR][/FONT]
[/COLOR][/COLOR][/FONT]
[/COLOR]
I start by this code but I didn't know how to complete
VB.NET:
[FONT=Courier New][COLOR=black]For i = 0 To Form1.DataGridView2.....Count - 1[/COLOR][/FONT]
[FONT=Courier New][COLOR=black][COLOR=black]cmd[/COLOR].CommandText = "INSERT INTO TBbills(BMaterial,BKind)[SIZE=2][COLOR=#800000]
[COLOR=black]VALUES (@Material,@BKind)[/COLOR]
[/COLOR][/SIZE][/COLOR][/FONT][FONT=Courier New][COLOR=black]cmd.CommandType = CommandType.Text[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]cmd.Parameters.AddWithValue("@BMaterial", Form2.DataGridView2...)[/COLOR][/FONT]
[FONT=Courier New][COLOR=black]cmd.Parameters.AddWithValue("@BKind", Form2.DataGridView2...[/COLOR][/FONT]
Last edited: