Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27569

VS 2010 Loop Through Dataset

$
0
0
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...

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

Thanks in advance

Viewing all articles
Browse latest Browse all 27569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>