locked
How to develop a two tier(client server application) application ???? RRS feed

  • Question

  • Hi !  I am a student new at programming though i have build few desktop application in vb.net but  i am completely unaware about client server architecture. I want to build a application for my school to maintain students and teachers database ,  this time i want to build a two tier (client server application using visual studio) but  i don't know where to start from . 

     

    My school has five computers for official use all running on Xp service pack 3 professional connected though LAN.

    I want use sqlserver 2008 express as my database and VB  as my programming language and my application type is windows form application .

    I know this much "i need a sever to host my database " but i don't know what should be the operating system of the server?? do i need a dedicated server running on a network operating system to serve five client or i can do that on Xp ???

    What are the basic requirements and knowledge i must have before developing a Clint server application...

     

    Any kind of help is appreciated !!!! 

     

    Sunday, March 13, 2011 7:54 AM

All replies

  • In the window application development, please do follow the simple rule

    Graphical user Intefrace( Winform or WPF) <==>  WCF <==> Data Access Layer <==> Sql Server 2008.

     

    In this application flow , the graphical user interface program can installed in various machines , the the GUI application can communicate with WCF Service which is residing in a single server where wcf service , DAL and sql server 2008 are installed.

     

    Sunday, March 13, 2011 1:03 PM
  •  

    I think what you just describe is 3(n)-tier application and not 2-tier:client server

    sql server 2008 express edition can be installed on xp with sp2 and above

    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b5d1b8c3-fda5-4508-b0d0-1311d670e336&displaylang=en

    Monday, March 14, 2011 6:12 PM
  • There are wide variety of design patterns you can follow depending on the application. The common goal for adopting one of them is with regards to the life time of the project, how much it could be expanded to, how hard would it be to maintain as it grows.

    Miss Eleanor , suggested you to go for the N-tier/ 3-tier(specifically). Its a very good design pattern and is easy to adapt to.

    You have 3 layers here:

    1) UI (commonly GUI)

    2) Business Logic (you have the services and model/logical code here)

    3) Data Layer

    One point, I would like to recommend is - don't host the database directly. I will give you a suggession on how I would implement, and you can take the points which you seem fit for your application.

    I would build a UI either in WPF or Windows Forms.

    WPF is better if you want to be inclined more towards the visual effects and have a fair idea or tendancy to learn XAML for the front end- though you would be using VB for the main coding part in the code-behind file. If you skip the animations and other features for now, you could build a simple application from WPF directly instead of Windows Forms and in the future, you can learn XAML and provide these features.

    Otherwise, please stick with Windows Forms - since they are very easy for beginners.

    Next would be the business logic layer. Here, the tendency is to use WCF. It provides the service oriented architecture- meaning that, you would be providing services to any User Interface(may it be command prompt/ GUI). All the logical part that you need goes into this layer, such as authentication of user. In general, you could say that this WCF acts like a server, to which your UI is the client. So, the servers main function is to accept incoming request, process it and give some response(in most cases).

    Next layer would be the Data Layer. This layer deals totally with your database, may it be accessing your database or getting some data from your database, refining it and then giving back the output of the database query. This is fully hidden and never made known to the end user. Your Service is the only thing that is given authorization to access this database. That way, no UI can know what your connection string is, where the database is, what table is being used, etc. Generally the tendancy is to give data to authorized/limited users and so, database is always kept securely as much as possible.

     

    Now coming to example:

    User uses the UI (the desktop user interface), presents his username and password - and then hits the button.

    The code behind takes the username and password - and gives it to the WCF service.

    The WCF service does internal processing such as make a call to the Data Layer with the username and password to check if the authorization has to be given. (Processing here could include adding a few extra parameters to the incoming username and password - usually a token is provided from the wcf service to data layer to make sure that the database knows that its communicating with the rightful WCF).

    The datalayer runs a query/stored procedure to check if the users identity is all right. If yes, then it passes a message back to the service saying yes else no.

    The service then passes the result back to the UI.

    The UI checks the result, and if the authentication is valid, then does some thing, like displaying the information about the logged in user or about the school, else displays that the user is not given permission to access.

    This is just to give a base idea. Once you have a base strategy, you can build an app and there on goto any depths as you feel right.

    Hope it helps.

     

    -------------------------

    Edit: It is entirely possible to implement this as a two -tier architecture by:

    1) Clubbing UI and business logic as one layer and database as second.

    2) UI as one and clubbing business logic and database as second.

    But it is not advisable to go for either of these. The drawback is that, they mess up in long run as well as you will be sacrificing lot of security issues. So, I would advise to go for atleast a 3-layer/tier architecture.

    • Edited by Nabil Shaik Tuesday, March 15, 2011 12:41 AM Adding extra information
    Tuesday, March 15, 2011 12:37 AM
  • All these computers are running on one LAN.

    There are 5 users.

    Why are people recommending WCF services?  Why a service layer at all?   

    I think this guy can easily make do with a smart car rather than a 32 wheeler.

    I would strongly recommend the simplest practical approach. 

    If you can get away with it, that might be strongly typed datasets which you can generate by drag and drop from the database.  Alternatively, entity framework will generate classes for you.

    Your "database server" doesn't need to be a server if you don't have one available.  It can be any machine that's backed up and secure.  Your XP machines would do. 

    Do you need to worry about concurrency?  Realistically.  Will users be maintaining the same data at all, let alone at the same time?

    The one thing I wouldn't totally skimp on is security.    I take it that these machines don't use active directory or anything you can leverage for security?

     It might be that only one machine needs to be used for data entry and you can split the application into one for writing data and one for reading.  With several machines just reading data.  That'd allow you to minimise the number of people who know write password(s).

    Tuesday, March 15, 2011 8:59 AM
  • Kudos to Andy, bring it back to analysing the problem rather than having technology find a problem to solve.
    http://pauliom.wordpress.com
    Tuesday, March 15, 2011 3:00 PM
  • One man's pragmatic minimalist is another's lazy git.  Depends on one's perspective. 

    It's possible to do this simpler.  Quicker and dirtier.

    Say the OP was a teacher who doesn't really want to learn .Net and just wanted some sort of pragmatic solution.  He could do this with an Access front end and sql server database. That'd be 2 tiers, come to think of it.

    Wednesday, March 16, 2011 8:50 AM
  • I apologize and I would like to accept that I didnt observe the LAN part in the thread.

    But despite that, I would still suggest to work with regard to it. (Its still a suggession - its ultimately upto the developer)

    This person is trying to make a stepping stone for a schools website. If I am not wrong, the issue of Legacy systems- the reason why we redo most projects from the start is not because the technology is outdated mostly but because the projects can never be maintained after certain period of time or they have to be cleaned out throughly.

    If by putting a little extra effort, he could do some extra work, then its going to be very advantageous to him. Not to forget that, his components are going to be loosely coupled. He could also fix problems pretty easily in the future due to the loose coupling.

    Furthermore, the school could go for a server at some point of time and at this time, the server doesnt have to be connected via LAN to the database.

    He will also have a wide range of expansion and a wider range of target environments/devices -such as mobile devices at a later stage??

    As long as he builds everything in a component wise manner and follows SOA, it would stay simple and he can keep track of everything very very easily.

    And in case, he wants to access data from a place that is not connected to the database system via a LAN, then his application wouldn't work. Assuming that his school has dorms and a school building, it would require that both of them to be interconnected or allow remote desktop connection.

    Basically, my point is, he can think of a near future and implement it, instead of just thinking about the current moment.

    But in the end, its upto him. If it has to be too simple,

    then I would suggest:

    1) Create tables on server(master)

    2) Use DataGrids - drag and drop (client) and then configure the datasource stuff.

    He doesnt need any design pattern, or any architecture. Its as simple as that.

    Wednesday, March 16, 2011 11:46 PM
  • I get the impression this guy's a complete beginner rather than an expert developer.  I could of course be wrong but it seems an odd sort of question if he's capable of components, SOA etc.

    If this system is to be the basis for an Enterprise sized solution I think my advice would be to hire a professional.

    Thursday, March 17, 2011 10:59 AM
  • You are right Andy I am a completely beginner as far as Clint server application is concerned. So what would be your best advice for me .. From where should i begin.
    Thursday, March 17, 2011 6:59 PM
  • Thankx Nabil it helped me to acquire more knowledge and to investigate more about 3 tier architecture.
    Thursday, March 17, 2011 7:01 PM
  • My pleasure.

    Manas, if you are at the very beginning level, say know how to create tables you need and little programming with vb.net, little knowledge about Datagrids component in the Toolbox of Visual Studio Windows Forms, then you can do a small neat application without much effort.

    Steps to create a new local database:

    1) Right click on solution and select Add>New Item

    2) Select Data from the left hand options and then select Local Database

    3) Give a name and hit Add

    4) Give a dataset name and finish the process.

     

    Upon doing it, you will have a database (.sdf file) and a dataset(.xsd file) added to your project.

    Now open the Server Explorer(View Menu > Server Explorer), and within the Data Connection tree-item,if you expand the node, you can find your database (.sdf file). In case it has a red-cross mark (indicates that you are not connected to it), right click it and say Refresh (this refreshes and connects to your database).

    If you can expand this database of yours, you can see a folder called Tables. (If you expand this node, initially it is going to be empty since you haven't created any tables). So, right click on this and select Create Table.

    You can create a table you desire very easily, by just filling out the rows it provides and configuring them. (Make sure you set one primary key such as Admission Number). This shall take care of your main table structure.

    To fill in the data, after you provide the table name and create the table structure and hit ok, you can expand the tables folder in the server explorer, right click on the table you desire and hit Show Table Data. You can click on the last row that is seen in the newly opened window(or panel), and that will give you to fill the data you wish to (If you have worked with Microsoft excel, then just like you fill data in each of the cells by clicking on them, you do it the same way here).

    Your database is done (unless you want to add more tables, dependencies etc).

    Building your front end:

    1) Double click on your form file in the solution explorer.

    2) From the toolbox (View Menu>ToolBox), drag and drop the DataGridView component (Its within the Data section)

    3) You can configure it using the small triangle shaped symbol at the top-right corner. By clicking on it, a small pop-up type panel comes.

    Click on the dropdownbox thats available there and select the link that says Add Project DataSource

    1) Select Database and hit next

    2) Dataset and next

    3) The connectionstring should be here by default - so, select the connection string that has your database name as the starting letters and select next (such as ManasDBConnectionString)

    4) Expand the tables node(only 1 level expanding is required, the 2nd expanding would give you the table column names) and check the table that you want to display - and hit Finish

    Thats it, your front end/GUI is done.

    Hit the run button and you can see the data from your table.

     

    Hope it helps you build the basic application. From then on you can complicate it and make it as complex as you want - such as have dropdownboxes in your form which would have values as student and teachers. And upon selecting one of those, it wil show the database corresponding to it and so on.

    Thursday, March 17, 2011 9:46 PM
  • Bear in mind that a local database is just that.  A database that is part of the application.

    So if you created such a database and then installed the app on 2 machines, each is using a database on their own machine rather than sharing one.

    You'd want one of the machines to hold the database and all to share this.  The connection string defines which machine and database is used.  Since you don't have a server you want to pick a machine that's always going to be on, isn't heavily used and is physically secure.

    One resource that I recall using a lot when I started doing .Net wnforms was George Shepherd's

    http://www.syncfusion.com/faq/windowsforms/default.aspx

    Hidden down in there are gems like...

    When you bind to a datatable you're actuually binding to a view of that.  There's an intermediate layer automagically created which you need to know about when you do certain stuff.

    Bear in mind that FAQ was put together a long time ago and some things might have moved on a bit.  Winforms binding changed rather a lot between vs2002 and vs2005.  Which is somewhat unfortunate as I could have given you (Manas) an old project to look at.

    If someone is a beginner then I think they either need a book or an experienced developer to sit with them and advise.  It's very easy to forget to mention imortant details in a forum post.  Especially when advising on a style of development one is unfamiliar with.

    Friday, March 18, 2011 9:15 AM
  • Monday, August 1, 2011 8:33 AM