unit - 1: introduction to front end – back end technology ...ksvelearn.org/csaunit4.pdf ·...

31
BCA Sem-IV Client Server UNIT-4 We can search the records in ADO.NET by using the following controls: o Combobox o Listbox o Radio Button o Text box o Checkbox We will do the following procedure to do the searching of records in our dataabse o Connect to the database by using the connection class o Open the connection o Make an object of data adapter. o Make an object of DataSet class o Drag and drop Datagridview from tools to form. o In the form load event, fill up the data set by using the fill () of data adapter. o In the TextBox1_TextChanged event, we will create an object of data view. o In the dv.RowFilter property we will put the search criteria using the ComboBox1.SelectedItem & " like '" & TextBox1.Text & "%'" o We will assign the result of dv to DataGridView1.DataSource property. o This sequence will be used for other kinds of searching also. Page 1 of 31

Upload: others

Post on 08-Apr-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

We can search the records in ADO.NET by using the following controls:oComboboxoListboxoRadio ButtonoText boxoCheckbox

We will do the following procedure to do the searching of records in our dataabse

o Connect to the database by using the connection classo Open the connectiono Make an object of data adapter.o Make an object of DataSet classo Drag and drop Datagridview from tools to form.o In the form load event, fill up the data set by using the fill () of data

adapter.o In the TextBox1_TextChanged event, we will create an object of data

view.o In the dv.RowFilter property we will put the search criteria using the

ComboBox1.SelectedItem & " like '" & TextBox1.Text & "%'"o We will assign the result of dv to DataGridView1.DataSource property.o This sequence will be used for other kinds of searching also.

Page 1 of 31

Page 2: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Program which will search the data using Combobox and TextBox

Imports System.DataImports System.Data.SqlClientPublic Class Form1 Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\pk.mdf;Integrated Security=True;User Instance=True") Dim adp As New SqlDataAdapter("select * from emp", cn) Dim ds As New DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("name") ComboBox1.Items.Add("section") ComboBox1.Items.Add("address") cn.Open() adp.Fill(ds) cn.Close() End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged cn.Open() Dim dv As New DataView(ds.Tables(0)) dv.RowFilter = "" & ComboBox1.SelectedItem & " like '" & TextBox1.Text & "%'" DataGridView1.DataSource = dv cn.Close() End SubEnd Class

Page 2 of 31

Page 3: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Program to search the data using Listbox and Textbox

Imports System.DataImports System.Data.SqlClientPublic Class Form1 Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\pk.mdf;Integrated Security=True;User Instance=True") Dim adp As New SqlDataAdapter("select * from emp", cn) Dim ds As New DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListBox1.Items.Add("name") ListBox1.Items.Add("section") ListBox1.Items.Add("address") cn.Open() adp.Fill(ds) cn.Close() End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged cn.Open() Dim dv As New DataView(ds.Tables(0)) dv.RowFilter = "" & ListBox1.SelectedItem & " like '" & TextBox1.Text & "%'" DataGridView1.DataSource = dv cn.Close() End SubEnd Class

Page 3 of 31

Page 4: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Program to search records using radio buttons

Imports System.DataImports System.Data.SqlClientPublic Class Form1 Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\pk.mdf;Integrated Security=True;User Instance=True") Dim adp As New SqlDataAdapter("select * from emp", cn) Dim ds As New DataSet Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged cn.Open() adp.Fill(ds) Dim dv As New DataView(ds.Tables(0)) If btnname.Checked = True Then dv.RowFilter = "name like '" & TextBox1.Text & "%'" DataGridView1.DataSource = dv ElseIf btnsection.Checked = True Then dv.RowFilter = "section like '" & TextBox1.Text & "%'" DataGridView1.DataSource = dv Else dv.RowFilter = "address like '" & TextBox1.Text & "%'" DataGridView1.DataSource = dv End If cn.Close() End SubEnd Class

Page 4 of 31

Page 5: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Crystal reports:o Visual Studio .NET is the first Windows development environment that

gives developers a fully integrated and robust reporting solution in the form of Crystal Report.

o Crystal Reports is now installed with Visual Studio so that developers can write applications that have reports seamlessly integrated into them.

o Starting with Visual Basic 3.0, Crystal Reports was included with the language, but not part of the default installation.

o It was also a stand-alone product that was independent of the programming language.

o With the release of Visual Studio.NET, Microsoft finally woke up to the needs of developers.

o They licensed Crystal Decisions to write a version of Crystal Reports to bethe default reporting solution installed with .NET.

o Built into the IDE, Windows developers now have the tools to write presentation-quality interactive reports.

Step by step procedure to develop Crystal Report using wizard technique

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_step_by_step.htm

o Open Visual Studio .NET and select a new Visual Basic .NET Project.

o Select Windows application from New Project Dialog Box.o Create a new database EmployeeDB database.

Page 5 of 31

Page 6: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o Create a new table Emp which has three fields. (Product_id, Product_name, Product_price).

o Enter some rows of data into the fields.o From the Project menu Click on Add New Item.

o Then select Crystal Reports from the dialogue box.

Page 6 of 31

Page 7: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o At this point, you may have to accept End User Agreement.o Click on YES, I Accept. If you do it, Crystal Report Gallery dialog box will

be visible.o Select Report type i.e. Using the Report Wizard from Crystal Reports

gallery.o From the Choose an Expert portion, select Standard.

o Then click OK. o The following Standard Report Creation Wizard will be visible.o Expand Create New Connection Treeo Next step is to Expand Access/Excel(DAO). The following dialog box will

be displayed.

Page 7 of 31

Page 8: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o Select database name from its location and click on FINISH.o The following screen will be visible.

Page 8 of 31

Page 9: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o Expand the table’s tree and select any table on which you want to make a report.

o The click on > button to shift the selected table to the right side under Selected table and click on NEXT.

o The following screen will be displayed.

o Shift the required fields from the LEFT side to Right side. these are the fields which you want to keep in your table.

o The click on FINISH.o Various sections of the report like detail, headers and footers of the report

will be displayed as shown in the following image

Page 9 of 31

Page 10: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o Now the designing part is over and the next step is to call the created Crystal Reports in VB.NET through Crystal Reports Viewer control.

o Select the default form (Form1.vb) you created in VB.NET and drag a button andCrystalReportViewer control to your form.

Page 10 of 31

Page 11: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o Select Form's source code view and write the following code on:

Imports CrystalDecisions.CrystalReports.Engine

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cryRpt As New ReportDocument cryRpt.Load("C:\Documents and Settings\PeeKay\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\CrystalReport1.rpt") CrystalReportViewer1.ReportSource = cryRpt CrystalReportViewer1.Refresh() End SubEnd Class

After you run the source code you will get the report like this.

And with this we have completed our creation of Crystal Report through Wizard.

Page 11 of 31

Page 12: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Procedure to Create a Simple Data Report:

1. Create a Windows Application using Visual Studio 2005.2. Drag and drop a ReportViewer control from Toolbox Data Tab to the

form.3. Now click on smart tag and click on DOCK IN PARENT CONTAINER.4. Right click on the Project Menu click on Add New Item.5. Select Report and click Add.

6. It will add Report.rdlc file to your project and will open the report designer, which looks like following Figure.

Page 12 of 31

Page 13: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

7. Data Sources tab will open up.8. Click on Add New Data Sources.9. Then click on Database Next.10.Then click on Add New Connection.

Page 13 of 31

Page 14: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

11.The following screen will come up where we will select MS Access database and click on continue.

12.Then click on Browse and select your database from the hard drive. Also you can test your connection at this place.

13.This is the same procedure which we have used to connect to our database.

14.Then click on OK and from the next screens click on Next YESNEXT.15.Then select the Tables and the name of the table, the data from which you

want to display in the report.16.Click on FINISH.

Page 14 of 31

Page 15: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

17.The following data sources tab will be displayed.

18.Now from the ToolboxReport items drag and drop one table control on the design area of the report (as displayed below).

Page 15 of 31

Page 16: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

19.Now from the data sources tab, drag and drop the fields on to the middle row of the table control which we have kept on the design area of the report.

20.Keep in mind that you can add or delete the columns from the displayed table.

21.Now again click on form1(design) and click on smart tag and select the name of the report.

22.Our task is now finished. Just run the programme, the following screen willbe visible and thereafter result will be displayed in the form of format as shown below.

Page 16 of 31

Page 17: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Summary:

o The ReportViewer control available in Visual Studio 2005 makes reporting easier for .NET developers.

o This article was a basic introduction to ReportViewer control and how to get started with it.

Page 17 of 31

Page 18: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Procedure to Create a Chart:

1. Create a database student.mdb in MS Access.2. Create a table stud which will have 02 fields i.e. name and marks.3. Enter some rows of data in the table.4. Create a Windows Application using Visual Studio 2005.5. Drag and drop a ReportViewer control from Toolbox Data Tab to the

form.6. Now click on smart tag and click on DOCK IN PARENT CONTAINER.7. Right click on the Project Menu click on Add New Item.8. Select Report and click Add.

9. It will add Report.rdlc file to your project and will open the report designer, which looks like following Figure.

Page 18 of 31

Page 19: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

10.Data Sources tab will open up.11.Click on Add New Data Sources.12.Then on the next screen click on Database Next.13.Then click on Add New Connection.

Page 19 of 31

Page 20: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

14.The following screen will come up where we will select MS Access database and click on continue.

15.Then click on Browse and select your database from the hard drive. Also you can test your connection at this place.

16.This is the same procedure which we have used to connect to our database.

17.At this point, you can also click on Test Connection.18.Then click on OK and from the next screens click on Next YESNEXT.

Page 20 of 31

Page 21: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

19.Then select the Tables and the name of the table, the data from which you want to display in the report.

20.Click on FINISH.

21.The following data sources tab will be displayed.

22.Now from the ToolboxReport items drag and drop one CHART control on the design area of the report (as displayed below).

Page 21 of 31

Page 22: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

23.Now from the Data sources, drag and drop marks field in DROP DATA FIELDS HERE portion and drag and drop name field in DROP SERIES FIELDS HERE portion of the chart.

24.Now again click on form1(design) and click on SMART TAG and select the name of the report.

25.Our task is now finished. Just run the programme, the following screen willbe visible and thereafter result will be displayed in the form of format as shown below.

Page 22 of 31

Page 23: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

o The chart displayed will be in different colors for every student.

Page 23 of 31

Page 24: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Complete application having searching and navigation

Imports System.DataImports System.Data.SqlClientPublic Class TestApp Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\EmployeeDB.mdf;Integrated Security=True;User Instance=True") Dim adp As New SqlDataAdapter("select * from EmpMst", cn) Dim cmd As New SqlCommand Dim ds As New DataSet Dim n As Integer = 0 Private Sub TestApp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cn.Open() filldataview() txtid.Text = ds.Tables(0).Rows(0).Item("id").ToString() txtname.Text = ds.Tables(0).Rows(0).Item("name").ToString() txtCity.Text = ds.Tables(0).Rows(0).Item("city").ToString() txtsalary.Text = ds.Tables(0).Rows(0).Item("salary").ToString() disableTextbox() End Sub Sub disableTextbox() txtid.Enabled = False txtname.Enabled = False txtCity.Enabled = False txtsalary.Enabled = False End Sub Sub enableTextbox() txtid.Enabled = True txtname.Enabled = True txtCity.Enabled = True txtsalary.Enabled = True End Sub Sub filldataview() cn.Close() cn.Open() adp.Fill(ds) dvList.DataSource = ds.Tables(0) End Sub

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click txtid.Text = ds.Tables(0).Rows(0).Item("id").ToString() txtname.Text = ds.Tables(0).Rows(0).Item("name").ToString()

Page 24 of 31

Page 25: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

txtCity.Text = ds.Tables(0).Rows(0).Item("city").ToString() txtsalary.Text = ds.Tables(0).Rows(0).Item("salary").ToString() End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click If btnAdd.Text = "add" Then btnAdd.Text = "Save" cleartextbox() enableTextbox() Else btnAdd.Text = "add" cmd.CommandText = "INSERT INTO EmpMst ([id], [name],[city], salary) VALUES ('" & txtid.Text & "','" & txtname.Text & "','" & txtCity.Text & "'," & txtsalary.Text & ")" cmd.Connection = cn cmd.ExecuteNonQuery() MsgBox("record added sucessfully.....") ds.Clear() filldataview() disableTextbox() End If End Sub

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click n = ds.Tables(0).Rows.Count txtid.Text = ds.Tables(0).Rows(n - 1).Item("id").ToString() txtname.Text = ds.Tables(0).Rows(n - 1).Item("name").ToString() txtCity.Text = ds.Tables(0).Rows(n - 1).Item("city").ToString() txtsalary.Text = ds.Tables(0).Rows(n - 1).Item("salary").ToString() End Sub

Sub navigation() txtid.Text = ds.Tables(0).Rows(n).Item("id").ToString() txtname.Text = ds.Tables(0).Rows(n).Item("name").ToString() txtCity.Text = ds.Tables(0).Rows(n).Item("city").ToString() txtsalary.Text = ds.Tables(0).Rows(n).Item("salary").ToString() End Sub

Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click If n = 0 Then MsgBox("you have reach on first record..") Else n = n - 1

Page 25 of 31

Page 26: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

navigation() End If End Sub

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click cmd.CommandText = "delete from EmpMst where id = '" & txtid.Text & "'" cmd.Connection = cn cn.Close() cn.Open() cmd.ExecuteNonQuery() cn.Close() MsgBox("record deleted sucessfully....") ds.Clear() filldataview() cleartextbox() End Sub Sub cleartextbox() txtid.Text = "" txtname.Text = "" txtCity.Text = "" txtsalary.Text = "" End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click If n = ds.Tables(0).Rows.Count - 1 Then MsgBox("you have reach at last record") Else n = n + 1 navigation() End If End Sub

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click If btnEdit.Text = "edit" Then btnEdit.Text = "update" enableTextbox() Else btnEdit.Text = "edit" cmd.CommandText = "update EmpMst set name='" & txtname.Text & "',city='" & txtCity.Text & "',salary='" & txtsalary.Text & "' WHERE id='" & txtid.Text & "'" cmd.Connection = cn

Page 26 of 31

Page 27: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

cn.Close() cn.Open() cmd.ExecuteNonQuery() MsgBox("record updated sucessfully...") ds.Clear() filldataview() disableTextbox() End If End Sub

Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged Dim dv As New DataView(ds.Tables(0)) If rbtnName.Checked = True Then dv.RowFilter = "name like '" & txtSearch.Text & "%'" dvList.DataSource = dv Else dv.RowFilter = "city like '" & txtSearch.Text & "%'" dvList.DataSource = dv End If End Sub

Private Sub dvList_CellClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles dvList.CellClick If Not IsDBNull(dvList.CurrentRow.Cells(0).Value) Then txtid.Text = dvList.CurrentRow.Cells(0).Value Else txtid.Text = "" End If If Not IsDBNull(dvList.CurrentRow.Cells(1).Value) Then txtname.Text = dvList.CurrentRow.Cells(1).Value Else txtname.Text = "" End If If Not IsDBNull(dvList.CurrentRow.Cells(2).Value) Then txtCity.Text = dvList.CurrentRow.Cells(2).Value Else txtsalary.Text = "" End If If Not IsDBNull(dvList.CurrentRow.Cells(3).Value) Then txtsalary.Text = dvList.CurrentRow.Cells(3).Value Else txtsalary.Text = "" End If End Sub

Page 27 of 31

Page 28: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

End Class

Page 28 of 31

Page 29: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Introduction to live network concept of Front end – back end technology

o Client-server is a computing architecture which separates a client froma server.

o Each client or server connected to a network can also be referred to asa node.

o The most basic type of client-server architecture employs only twotypes of nodes: clients and servers.

o This type of architecture is also sometimes known as two-tier. o Each client can send data requests to connected server. o In turn, the server can accept these requests, process them, and return

the requested information to the client. o Although this concept can be applied for a to many different kinds of

applications, the architecture remains fundamentally the same.o These days, clients are most often web browsers but this is not

necessary. o Even your VB.NET application can request the data from a database

server on the network.o In this case your application will be client and your database server on

the network will be Server.o Servers typically include web servers, database servers and mail

servers. o Online gaming is an example of client-server too.

Page 29 of 31

Page 30: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

Characteristics of a client:-

• Request sender is known as client • client initiates the requests • client waits and receives replies. • Typically interacts directly with end-users using a graphical user interface (GUI).

Characteristics of a server:-

• Server is receiver of request which is send by client • Upon receipt of requests, processes them and then serves replies to client• Usually accepts connections from a large number of clients • Typically does not interact directly with end-users

The following are the examples of client/server architectures:-

1) Two tier architectures

o In two tier client/server architectures, the user interface is placed atuser's desktop environment and the database management systemservices are usually in a server that is a more powerful machine thatprovides services to the many clients.

o Information processing is split between the user system interfaceenvironment and the database management server environment.

o The database management server supports technology used formanaging the data.

2) Multi-tiered architecture

o Some designs are more sophisticated and consist of three different kindsof nodes: clients, application servers which process data for the clientsand database servers which store data for the application servers.

o This configuration is called three-tier architecture, and is the mostcommonly used type of client-server architecture.

o Designs that contain more than two tiers are referred to as multi-tiered orn-tiered.

o We have already seen the advantages of n-tiered architectures.o This in turn improves overall system performance and reliability, since

more of the processing load can be accommodated simultaneously.

Page 30 of 31

Page 31: Unit - 1: Introduction to Front end – Back end technology ...ksvelearn.org/CSAunit4.pdf · created Crystal Reports in VB.NET through Crystal Reports Viewer control. o Select the

BCA Sem-IV Client Server UNIT-4

We will now study a program which will explain the Live Concept of client-server. In this example, we keep our database on server (on another computer which is connected to the network in which our pc is connected) and we will interact with that database using a client program which is on another computer.

Imports System.DataImports System.Data.SqlClientPublic Class Form1 Dim cn As New SqlConnection("Data Source=172.16.16.5;Initial Catalog=vishal;Persist Security Info=True;User ID=sa;password=1212;pooling=false")

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cn.Open() If cn.State = ConnectionState.Open Then MsgBox("done") Else MsgBox("not done") End If cn.Close() End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click cn.Open() Dim adp As New SqlDataAdapter("select * from emp", cn) Dim ds As New DataSet adp.Fill(ds) DataGridView1.DataSource = ds.Tables(0) cn.Close() End SubEnd Class

Page 31 of 31