0

I can't seem to wrap my head around this. I'll need a seasoned programmer to push in the right direction. I have a listView with 7 sub items. What I'm looking to do is populate a table in an .mdb file with the data. The listView box is almost the same as the .mdb table I'm attempting to populate. It contains a static number of rows and about 10 columns (some of the columns will be populated with static data others with the dynamic data from the listview.

cnn.Open(); //Open database connection
foreach (ListViewItem toSenditems in this.listView1.Items)
{
     //insert a new row in the table
     for (int i = 0; i < toSenditems.SubItems.Count; i++)
     {
      //Fill the row with sub items
     }
}
cnn.Close();

I can't figure out where in the loops to place my ExecuteNonQuerys and how to structure my sqlcommands.

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by riahc3
0

I can't figure out where in the loops to place my ExecuteNonQuerys and how to structure my sqlcommands

My recommendation is to make subfunctions such as

(Psuedocode)

function insert(string table, string data, string whereclause)
 {
         //comands to insert structured correctly
      }

This make life a lot more simpler when you are going to be working a lot with databases.

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.