I want each individual item inserted into database as a new entry. Right now, I am only able to insert all items into the database as a single entry. I am trying to add 3 book names in the database with the same borrowerId. can anyone help me? because im a beginner.
here is my code:
foreach (ListViewItem item in this.lb_bookList.Items)
{
for (int i = 0; i < item.SubItems.Count; i++)
{
int bookId = i;
//Inserting into a database
String requestBook = "INSERT INTO tbl_borrowedbooks(BorrowerID, BookID, DateRequested, Status) Values('" + getUser + "','" + bookId + "','" + date + "'," + "' Requested')";
MySqlCommand datacommand = new MySqlCommand(requestBook, databaseConnection);
databaseConnection.Open();
datacommand.ExecuteReader();
}
}