title: SQL select query in asp.net
body: <p>Can anyone tell me how to get the value from <code>SELECT</code> query from a table  </p>
  
  <pre><code>protected void Button_Click(object sender, EventArgs e)
  {
     string select_qry = "SELECT ID, USER, FILE, DATE, LASTUSED from FILE_INFO where USER = '" + user + "'"; // ID is primary key
     SqlCommand cmd = new SqlCommand(select_qry);
     GridView1.DataSource = GetData(cmd);
     GridView1.DataBind();
  }
  
  private DataTable GetData(SqlCommand cmd)
  {
     DataTable dt = new DataTable();
     SqlDataAdapter sda = new SqlDataAdapter();
     cmd.CommandType = CommandType.Text;
     cmd.Connection = conn1;
     conn1.Open();
     sda.SelectCommand = cmd;
     sda.Fill(dt);
     return dt;
  }  
  </code></pre>
  
  <p>I have different USERS I want to get ID of user if user is different say 'Sheena' has ID value from 1-10 but if user is 'Sara' and she is having ID from 11-20 so I want to get specially ID of particular user how do I get ID from select query can any one know then please help me out :)</p>