Read one-by-one record from Table

try
{
    // SqlCommand command = new SqlCommand("select * from empdata where id ='"+TextBoxID.Text+"'", connection);
    // connection.Open();
    // SqlDataReader reader = command.ExecuteReader();

//     if (reader.HasRows)
  //   {
    //     while (reader.Read())
      //   {
        //     //Assign to your textbox here  
          //   NameTextBox.Text = reader["name "].ToString();
            // AddressTextBox.Text = reader["address "].ToString();
            //SalaryTextBox.Text = reader["salary"].ToString();
         //}
    // }
Instead of above solution we can try this too Disconnected Architecture 
SqlDataAdapter da = new SqlDataAdapter("select * from EmpData where id = '" + txtEmployeeName.Text + "'", con);
                DataTable dt = new DataTable();
                da.Fill(dt);
                txtEmployeeAddress.Text = dt.Rows[0]["Salary"].ToString();    

 }
catch (SqlException ex)
{
    Response.Write(ex.Message.ToString());
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s