Amanpreet_1 0 Light Poster

i declared a variable string to store my query video_id value in it Inline Code Example Here string videoid;

   private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            loaddata();
            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();

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

        } and then passed it my another funct.  void loaddata()
        {
            MessageBox.Show(videoid);
            string myconnection = "connection string";
              MySqlConnection myConn = new MySqlConnection(myconnection);


              MySqlCommand SelectCommand1 = new MySqlCommand("select u_id from livestream.views inner join livestream.video on views.video_id = video.video_id and views.u_id = video.user_id where title ='" + channeltitle.Text+"' and views.video_id ='"+ ***videoid*** +"' " , myConn);
              MySqlDataReader myReader;


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

                  while (myReader.Read())
                  {

                      string uID = myReader.GetString("u_id");
                      list.Add(uID);
                      // user.LastName = (string)dr["lastName"];
                      // user.Email = (string)dr["email"];
                      // user.Username = (string)dr["userName"];
                      // user.Password = (string)dr["password"];
                      // user.type = (string)dr["type"];  
                      // chattingbox.Text = chat;

                  }
                  viewerlist.Lines = list.ToArray();

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

        }



        }




    } the video id i used here is giving me random results nt according to what i got from previous query ..... please help me getting d key poinyt , whr m i makin mistake 
Be a part of the DaniWeb community

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