Reputation: 35
I am using SQL in vb.net. I believe I have successfully connected to the database and at the moment I am able to display the information I have received in a message box with:
sql = "SELECT ID FROM LoginInformation WHERE Username = '" & txt_Username.Text & "' AND Password = '" & txt_Password.Text & "'"
DataSets = database.sqlSelect(sql)
MsgBox(DataSets.Tables("LoginInformation").Rows(0).Item(0))
However, I do not want it to show the same cell of the database every time I use this code and I am unsure as to how to display what I am actually looking for with the SQL statement. From the above code, I have tried to find the 'ID' but it will always display the cell located at (0,0)
Any help will be appreciated!
Thanks.
Upvotes: 1
Views: 983
Reputation:
You should loop throw this DataSets.Tables("LoginInformation")
to get all the rows and columns.
See this example quoted from here:
Private Sub PrintRows(ByVal dataSet As DataSet)
Dim table As DataTable
Dim row As DataRow
Dim column As DataColumn
For Each table in dataSet.Tables
For Each row In table.Rows
For Each column in table.Columns
Console.WriteLine(row(column))
Next column
Next row
Next table
End Sub
Upvotes: 1