[WebMethod]
public ArrayList GetPersonArrayList()
{
SqlConnection dbConn = new SqlConnection(connStr);
dbConn.Open();
string sqlSelect = "select * from users ";
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
DataTable dt = new DataTable();
SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
da.Fill(dt);
dbConn.Close();
ArrayList myList = new ArrayList();
foreach (DataRow row in dt.Rows)
{
Person target = new Person();
target.Name = row["Name"].ToString();
target.UserName = row["UserName"].ToString();
target.EMail = row["EMail"].ToString();
target.Password = row["Password"].ToString();
myList.Add(target);
}
return myList;
}
[WebMethod(Description = "Method to obtain All User Info")]
public Person[] ReturnArray()
{
SqlConnection dbConn = new SqlConnection(connStr);
dbConn.Open();
string sqlSelect = "select * from users ";
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
DataTable dt = new DataTable();
SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
da.Fill(dt);
dbConn.Close();
List
foreach(DataRow row in dt.Rows) {
// Person target = Activator.CreateInstance
Person target = new Person();
target.Name = row["Name"].ToString();
target.UserName = row["UserName"].ToString();
target.EMail = row["EMail"].ToString();
target.Password = row["Password"].ToString();
// DataColumnAttribute.Bind(row,target);
list.Add(target);
}
return list.ToArray();
}
No comments:
Post a Comment