i've made a form which is supposed to display the result from

 "select COUNT() from CleaningStatus where Status = 'Cleaning'"
query

ive tried :

SqlConnection connection = new SqlConnection();
                connection.ConnectionString =
                    "Data Source = moi-pc/SQLEXPRESS; Initial Catalog
= Project; User ID = sa ;Password = madurai";
                connection.Open();
                SqlDataReader myReader = null;
                query = "select COUNT() from CleaningStatus where
Status = 'Cleaning'";
                SqlCommand myCommand = new SqlCommand(mainquery,
connection);
                SqlCommand myCommand2 = new SqlCommand
(query1,connection);

                myCommand.Parameters.Add(new SqlParameter());
                SqlDataReader dr = myCommand.ExecuteReader();


                userCount = (int)myCommand.ExecuteScalar();


                while (dr.Read())

                while (myReader.Read())
                {
                    userCount = Convert.ToInt32(textBox3.Text);
                    textBox3.Text = myReader[1].ToString();

                }
            }
            catch
            {
                Console.WriteLine("failed");
            }

BUT i dont think im getting anywhere

any help will be greatly appreciated

Reply via email to