Mohammed Salim

Mohammed Salim

  • 1.9k
  • 56
  • 1.7k

SQL Select based on user input

May 15 2018 12:49 PM
I m trying to retrieve no of rows from sql based user input & display in gridview
 
Please help!
 
This is code what I'm using
  1. Int32 text = Convert.ToInt32(this.Txtusers.Text);  
  2. con.Open();  
  3. cmd = new SqlCommand("select TOP '" + text + "' * from Avaya_Id where LOB = '" + DDLOB.SelectedItem.Value + "' and Status = 'Unassigned'", con);  
  4. SqlDataReader rdr = cmd.ExecuteReader();  
  5. GridView1.DataSource = rdr;  
  6. GridView1.DataBind();  
  7. con.Close();  

Answers (1)