Exemplo n.º 1
0
        public employee search(int i)
        {
            SqlConnection con = getconnection();
            employee      e   = new employee();
            SqlCommand    sc  = new SqlCommand("select * from emp where id = @abc", con);

            con.Open();
            sc.Parameters.AddWithValue("@abc", i);
            SqlDataReader sd = sc.ExecuteReader();

            if (sd.HasRows)
            {
                while (sd.Read())
                {
                    e.Id     = Convert.ToInt32(sd["id"]);
                    e.Name   = sd["name"].ToString();
                    e.Salary = Convert.ToSingle(sd["salary"]);
                    break;
                }
            }
            return(e);
        }