Hi,
Can anyone help me with looping through a dataset?
I'm currently trying to get all the ingredients for a recipe into a textbox and my code only gets the first ingredient because it looks at the rows.
I'm wanting to loop through the rows to get all the ingredients and display them .
Here's my code at the moment...
Thanks in advance
Can anyone help me with looping through a dataset?
I'm currently trying to get all the ingredients for a recipe into a textbox and my code only gets the first ingredient because it looks at the rows.
I'm wanting to loop through the rows to get all the ingredients and display them .
Here's my code at the moment...
Code:
Dim dsIngredients As New DataSet
'find it in the database and get the ingredients
Dim ingredientssql As String = "SELECT Ingredients.IngreID, Ingredients.IngreName, Ingredients.IngreAmount, Ingredients.IngreUnit FROM Ingredients WHERE Ingredients.RecipeNumber=" & IntNum & ";"
'display the ingredients
ConnectToDataBase()
Dim tableAdaptor As New OleDb.OleDbDataAdapter(ingredientssql, dbConnection)
tableAdaptor.Fill(dsIngredients, "Ingredients")
Dim IngredientsText As String = dsIngredients.Tables("Ingredients").Rows(0).Item(2) _
& dsIngredients.Tables("Ingredients").Rows(0).Item(3) & _
" " & dsIngredients.Tables("Ingredients").Rows(0).Item(1)
IngredientsTextBox.Text = IngredientsText