i retrieved my values in a default array from sql query ,, bt evn if i have one element in my array m getting a list of items ,, y ? can anyone help me

Recommended Answers

I don't really understand your question. Could you try and explain it again please?

Jump to Post

Please post your code. How are you declaring the array?

Jump to Post

Have you check the value for videoid is a valid value? Did you also run the query against the database manually and check the result?

What type of object is viewerlist?

Jump to Post

All 10 Replies

I don't really understand your question. Could you try and explain it again please?

Please post your code. How are you declaring the array?

  string videoid;
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            string myconnection = "connection string";
            MySqlConnection myConn = new MySqlConnection(myconnection);
            MySqlCommand SelectCommand = new MySqlCommand("select * from livestream.video where  title ='" + channeltitle.Text + "' and active=1  ", myConn);
            MySqlDataReader myReader;


            try
            {
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();

                while (myReader.Read())
                {
                    //int videoid = Convert.ToInt16(myReader["video_id"]);
                    videoid = myReader.GetString("video_id");
                    MessageBox.Show(videoid);

                }
                chatting();
                loaddata();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            myConn.Close();

        }
        void loaddata()
        {

            // MessageBox.Show(videoid);
            string myconnection = "connection string";
            MySqlConnection myConn = new MySqlConnection(myconnection);

            MySqlCommand SelectCommand = new MySqlCommand("select * from livestream.views where video_id ='" + videoid + "' and ACTIVE=1  ", myConn);

            MySqlDataReader myReader;


            try
            {
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();
                List<string> list = new List<string>();

                while (myReader.Read())
                {
                  string userID = myReader.GetString ("u_id");
                    list.Add(userID);

                }

             viewerlist.Lines = list.ToArray();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            myConn.Close();

        }

please tell me y ? m i getting default answer

look at this .... it is hw'z itz a default value wich is returned .. m not getting y ???

Have you check the value for videoid is a valid value? Did you also run the query against the database manually and check the result?

What type of object is viewerlist?

  viewerlist.Lines = list.ToArray();

where does this come from?

viewerlist is a richtextbox and yes the videoid m passing is giving me the ryt result as i have declared it gloabally ......

;;;;;;;;

viewerlist.Lines = list.ToArray(); castajiz 2 it comes from a default array i declared to enter the values into the richtextbox from a query ..

even by clearing the viwerlist by viewlist.clear(); thrz no use //// :-( plzzzz guide me ,,, m stuck and hv tired many tymzz

MySqlCommand SelectCommand = new MySqlCommand("select * from livestream.views where video_id ='" + videoid + "' and ACTIVE=1 ", myConn); when you insert a breakpoint on this line. What is the value of the videoid ? and when you run this directly in SQL how many values are returned?

Try this when you step your code hover over the select command and use the text visualizer and copy the code directly into SQL

m done thankyuuuuuu fenrir ....... it was ryt... jux dint show ol results in ma sql ... so was ma answer nt matchinn ....... thnkyuuu ones again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.