E
Eudin
Guest
Hi, I am currently developing a simple application, a 3 tier architecture, I want to populate my listview in my presentation layer, but from my business logic layer with SQLdata reader.
This is my code in my BLL, but how will I be able to populate my listview
in my presentation layer from a different class? I have tried Arraylist and List, but I may be using it in the wrong way,
can someone help me please. Thank you
public void LoadToListView()
{
DBConnector.connection.Open();
cmd = new SqlCommand("SELECT * FROM UserInfo");
cmd.Connection = DBConnector.connection;
reader = cmd.ExecuteReader();
while (reader.Read())
{
User_ID = int.Parse(reader["UserID"].ToString());
First_Name = reader["FirstName"].ToString();
Middle_Name = reader["MiddleName"].ToString();
Last_Name = reader["LastName"].ToString();
Email = reader["EmailAddress"].ToString();
Mobile = reader["Mobile"].ToString();
}
DBConnector.connection.Close();
}
This is my presentation Layer...
private void btnPopulateListview_Click(object sender, EventArgs e)
{
listViewUser.Items.Clear();
user.LoadToListView();
ListViewItem userList = new ListViewItem(user.User_ID.ToString());
userList.SubItems.Add(string.Format("{0} {1} {2}", user.First_Name, user.Middle_Name, user.Last_Name));
userList.SubItems.Add(user.Email);
userList.SubItems.Add(user.Mobile);
listViewUser.Items.Add(userList);
}
Continue reading...
This is my code in my BLL, but how will I be able to populate my listview
in my presentation layer from a different class? I have tried Arraylist and List, but I may be using it in the wrong way,
can someone help me please. Thank you
public void LoadToListView()
{
DBConnector.connection.Open();
cmd = new SqlCommand("SELECT * FROM UserInfo");
cmd.Connection = DBConnector.connection;
reader = cmd.ExecuteReader();
while (reader.Read())
{
User_ID = int.Parse(reader["UserID"].ToString());
First_Name = reader["FirstName"].ToString();
Middle_Name = reader["MiddleName"].ToString();
Last_Name = reader["LastName"].ToString();
Email = reader["EmailAddress"].ToString();
Mobile = reader["Mobile"].ToString();
}
DBConnector.connection.Close();
}
This is my presentation Layer...
private void btnPopulateListview_Click(object sender, EventArgs e)
{
listViewUser.Items.Clear();
user.LoadToListView();
ListViewItem userList = new ListViewItem(user.User_ID.ToString());
userList.SubItems.Add(string.Format("{0} {1} {2}", user.First_Name, user.Middle_Name, user.Last_Name));
userList.SubItems.Add(user.Email);
userList.SubItems.Add(user.Mobile);
listViewUser.Items.Add(userList);
}
Continue reading...