Like below
Code
public class Class
{
public ArrayList GetInfos(string NAM)
{
ArrayList list = new ArrayList();
string str = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(str);
SqlCommand cmd = new SqlCommand("SELECT SURNAME,NAM,LASTNAME,BIRTHDAY,ADDRESS FROM INFO WHERE NAM=" + NAM, con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
list.Add(string.Join(";", rdr["SURNAME"], rdr["NAM"], rdr["LASTNAME"], rdr["BIRTHDAY"], rdr["ADDRESS"]));
}
return list;
}
}
In the page on button click.
protected void btnAdd_Click(object sender, EventArgs e)
{
Class class1 = new Class();
string name = "abc";
class1.GetInfos(name);
}