Violeta Popa

Violeta Popa

  • NA
  • 137
  • 163.7k

dataReader doesn't read

Apr 16 2013 4:05 PM
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)