Display table of values

uberamd

Member
Joined
Jan 22, 2007
Messages
9
Programming Experience
Beginner
Currently the table of values that are fetched from the database display like so:

app.gif


However I would like to know if it is possible to display it in a vertical matter, where the column titles are row titles, and the values go in the second column all the way down.

Code:
VB.NET:
    Private Sub frmBody()
        SQL = "SELECT * FROM account WHERE username='" & Convert.ToString(txtUser.Text) & "' AND password='" & Convert.ToString(txtPass.Text) & "'"

        Try

            Try
                myCommand.Connection = conn
                myCommand.CommandText = SQL

                myAdapter.SelectCommand = myCommand
                myAdapter.Fill(myData)

                dgvStatus.DataSource = myData
                dgvStatus.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
            Catch myerror As MySqlException
                MsgBox("There was an error reading from the database: " & myerror.Message)
            End Try
        Catch myerror As MySqlException
            MessageBox.Show("Error connecting to the database: " & myerror.Message)
        Finally
            If conn.State <> ConnectionState.Closed Then conn.Close()
        End Try
    End Sub

Lastly, how do I check to see if a query returns no rows? I would like the login to prompt the user if they input a incorrect username but my wonderful VisualBASIC .NET textbook does not cover that at all.

Thanks in advance!
 
If myData is a datatable then check for something like myData.Rows.Count.

To transpose the grid, you could display the data in 4 labels/textboxes. Is it editable?
 
Back
Top