hi friends,
I want to develop 3 tier app but I still confused how to implement it

1. In data access layer, could I return datareader? it's the better approach? some people tell it is not good way, you better used arrayList.

2. I have one method with 3 transaction inside (insert, update, delete)
I make this in business layer, so that the OleDBConnection (open and close), OleDbTransaction placed in business layer and I pass this as parameter to data access layer, is that good way?

3. if anyone have the good tutorial especially in C#, please tell me.

Thanks

Recommended Answers

All 4 Replies

Learn the Entity Data Model.
1. http://msdn.microsoft.com/en-us/library/aa697428%28VS.80%29.aspx
2. http://msdn.microsoft.com/en-us/library/aa697427%28VS.80%29.aspx

Thanks for the answer, but it's to complicated, I need more time to learn it, while I have deadline.
I give u my code please tell me + -

DAL

public static OleDbDataReader GetAll(OleDbConnection conn, bool status)
        {
            try
            {
                string query =
                    "SELECT [Id], [Name], [CreatedDate], [CreatedBy], " +
                    "   [UpdatedDate], [UpdatedBy] " +
                    "FROM [Role] " +
                    "WHERE [Status] = @pStatus " +
                    "ORDER BY [Name] ASC";

                OleDbCommand cmd = new OleDbCommand(query, conn);
                OleDbParameter pStatus = cmd.Parameters.Add("@pStatus", 
                    OleDbType.Boolean);
                pStatus.Value = status;
                OleDbDataReader dr = cmd.ExecuteReader();

                return dr;
            }
            catch (OleDbException ex)
            {
                throw new Exception("OleDb Error: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

BLL

public List<Role> GetAll(bool status)
        {
            List<Role> listRole = new List<Role>();

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                OleDbDataReader dr = RoleData.GetAll(conn, status);

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Role role = new Role();
                        role.Id = int.Parse(dr["Id"].ToString());
                        role.Name = dr["Name"].ToString();
                        role.CreatedBy = dr["CreatedBy"].ToString();
                        role.CreatedDate = (string.Empty.Equals(dr["CreatedDate"].ToString()) ?
                            DateTime.MinValue :
                            DateTime.Parse(dr["CreatedDate"].ToString()));
                        role.UpdatedBy = dr["UpdatedBy"].ToString();
                        role.UpdatedDate = (string.Empty.Equals(dr["UpdatedDate"].ToString()) ? 
                            DateTime.MinValue : 
                            DateTime.Parse(dr["UpdatedDate"].ToString()));
                        listRole.Add(role);
                    }
                }

                return listRole;
            }
            catch (OleDbException ex)
            {
                throw new Exception("OleDb Error: " + "\n" + ex.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.