Solved

3-tier architecture asp.net Multi domains dbase driven website

Posted on 2004-10-17
3
217 Views
Last Modified: 2012-08-13
Hi
i have posted before http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21127643.html about having multi domains pointing to the same website. I am an asp devolper but i am going to advice my staff to rebuild the whole application with asp.net.
The senario is like that.
I want to build 3-tier architecture for my application and i need to know that i am in the right way.
1- i will use stored procedures to store all the dbase realted issues.
2- i will use views in the dbase to get the recordsets for each domain (basically the same functions but each domain will get the results from the realted categories)
3- i am not sure how to get the business logic away from the presentaion
4- i do not know how to allow the .net to use different layouts with each domain. basically what is the techniques used.
5- the application should be multilangual , is that a complicated process with multi layouts.
i need detailed information and links to usefull resources.
Thanks in advance for all the help
0
Comment
Question by:mohmedsh
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
MikeMCSD earned 500 total points
ID: 12447685
THIS IS A SIMPLE PRESENTATION, BUSINESS, DATABASE 3-TIER EXAMPLE.
HERE I'M GETTING THE LIST OF CATEGORIES FROM THE SQL SERVER DATABASE:

PUT THIS IN YOUR Web.config, THIS IS THE GLOBAL CONNECTION TO THE DATABASE:

    <appSettings>
   <add key="ConnectionString"  
           value="server=localhost;Trusted_Connection=true;database=MY_DATABASE"/>
    </appSettings>

THIS IS THE .ASPX PAGE THAT WILL DISPLAY THE RESULTS (PRESENTATION)
I'M USING A DATALIST BECAUSE THEY HAVE A LOT OF FEATURES BUILT IN:

<asp:DataList Width="100%" id="list" runat="server" CellPadding="0">
<ItemTemplate>
<TABLE cellSpacing=0 cellPadding=0 width=100% border=0>
<TBODY>
<TR>
<TD vAlign=top>
<A id="hyp2" runat="server" href='<%#  DataBinder.Eval(Container.DataItem, "Name") %>' style="cursor: pointer;">
<IMG height=60 width=60 src='images/catsec/<%# DataBinder.Eval(Container.DataItem, "ImagePath") %>' border=0></A></TD></TR>
<TR>
<td align=left bgcolor=#f7f7f7>
<font class="PDesc"> <%# DataBinder.Eval(Container.DataItem, "description") %> </font>
</TD></TR>
</TBODY></TABLE>
</td></tr>
</TBODY></TABLE><br>
</ItemTemplate>
</asp:DataList>

IN THE CODE BEHIND FOR THAT PAGE, ASPX.VB, PUT:

'I'M GETTING PARAMETER FROM QUERY STRING TO PASS TO THE FUNCTION:
Dim departmentId As String = Request.QueryString("DepartmentID")

'I'M CALLING A FUNCTION TO FILL THE DATALIST WITH:
        list.DataSource = Catalog.GetCategoriesInDepartment(departmentId)
        list.DataBind()


BUSINESS LOGIC
MAKE A CLASS FILE CALLED Catalog.vb . . and put the function(s) in it:

Public Class Catalog

Public Shared Function GetCategoriesInDepartment(ByVal departmentId As String) As SqlDataReader
        Dim connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand("GetCategoriesInDepartment", connection)
        command.CommandType = CommandType.StoredProcedure
        command.Parameters.Add("@DepartmentID", SqlDbType.Int, 4)
        command.Parameters("@DepartmentID").Value = departmentId
        Try
            connection.Open()
            ' Return an SqlDataReader to the calling function
            Return command.ExecuteReader(CommandBehavior.CloseConnection)
        Catch e As Exception
            connection.Close()
            Throw e
        End Try
    End Function

'ADD THIS ALSO, THIS IS THE CONNECTION STRING PROPERTY FOR THE DATABASE:

Private Shared ReadOnly Property connectionString() As String
        Get
            Return ConfigurationSettings.AppSettings("ConnectionString")
        End Get
    End Property

End Class


THIS IS THE STORED PROCEDURE THAT THE FUCTION USES:

CREATE PROCEDURE GetCategoriesInDepartment
      (@DepartmentID int)
AS

SELECT CategoryID, [Name], [Description], ImagePath
FROM Category
WHERE DepartmentID = @DepartmentID


THIS IS A SIMPLE EXAMPLE THAT SHOWS THE 3 LAYERS.
IF YOU HAVE ANY QUESTION JUST ASK.

0
 
LVL 16

Expert Comment

by:MikeMCSD
ID: 12452852
I highly recommed this book.  It explains the 3-tier approach.
It also gives a lot of tricks and techniques on ASP.NET.
Great book!


http://www.amazon.com/gp/product/customer-reviews/1590592549/ref=cm_cr_dp_2_1/102-3787577-5262502?%5Fencoding=UTF8&me=ATVPDKIKX0DER
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now