I need to list Database data, each in a component, if any. in C# . NET Visual Studio

Asked

Viewed 21 times

0

In C#, visual Studio. hello I am new and come for help, I would like to display in a component, can be in the textbox, Panel or label the data of table 'OCCUPATIONS'. I’ll try to explain:

I have a table called 'OCCUPATIONS' where I have the fields: ID, ROOM, DATA, HOST. When I make a reservation, the fields: ID, QUARTO, DATA, HOSPEDE receives the respective values. When I check out, the fields: ID, ROOM, DATE, GUEST are blank, indicating that there are no reservations. What I would like is to display the ROOM field on a component if there is a value. If it is empty, it does not display or turn green. Can someone give me some guidance? I can already list in a grid, and count the elements and even pick up the field with Reader, but only takes a data.

to list: "SELECT * FROM occupations ORDER BY quarto asc"; to check: cmdVerify = new Mysqlcommand("SELECT * FROM rooms WHERE room = @room", con.con);

help me

1 answer

0

Whenever you want to read a new piece of data you need to use the Reader.Read() function I recommend using the following snippet that checks if the Reader has data and proceeds to create a while that reads line by line:

if (reader.HasRows)
        {
            while (reader.Read())
            {
                // ATUALIZAR A DATAGRID AQUI
            }
        }
  • I managed to solve this case. Now the problem is another. My if (Quartoocupado == "01") I am limited to room quantity "01", "02"... I need an if (Quartoocupado == Quartocadastrado). where I look for rooms in the table 'Rooms'. any suggestions?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.