0

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

4
Contributors
10
Replies
44
Views
3 Years
Discussion Span
Last Post by Amanpreet_1
0
  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

0

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

Attachments problm.png 296.16 KB
0

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?

0

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 ..

Edited by Amanpreet_1

0

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

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.