5
Reply

dataReader doesn't read

Ask a question
Violeta Popa

Violeta Popa

11y
1.1k
1
Hi :) I am trying to read some information from the database, but i don't know why this reader doesn't work. I've checked in the database and i have the client with that id.

                int nr_dauna = 0;
            string selectDauna = "SELECT * FROM dauna WHERE id_client='" + 16 + "'";
            SqlCommand executaSelectDauna = new SqlCommand(selectDauna, conn);
            SqlDataReader rdr_dauna = executaSelectDauna.ExecuteReader();
            rdr_dauna.Read();
            nr_dauna = Convert.ToInt32(rdr_dauna["nr_dauna"]);
            rdr_dauna.Close();
            MessageBox.Show(nr_dauna.ToString());

It's sth wrong? Or maybe there is another way of reading database info?Thanks!

Answers (5)