You are on page 1of 38

Date-

Enroll No-

PRACTICAL: 1

AIM: An Introduction about .NET framework with comparison of various Frame work versions.
The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The.NET framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform. The frameworks Base Class Library provides a large range of features including user interface, data and the data access, database connectivity, cryptography, web application development, numeric algorithms and network communications. The class library is used by programmers, who combine it with their own code to produce applications. Programs written for the .NET Framework execute in a software environment that manages the programs runtime requirements. The runtime environment is known as the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine so that programmers need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other important services such as security, memory management and exception handling. The class library and CLR together constitute the .NET Framework. .NET is a cluster of different technologies. It includes:: 1. The .NET languages: that includes C# and Visual Basic .NET, the object-oriented and modernized successor to Visual Basic 6.0. 2. The Common Language Runtime (CLR): the .NET runtime engine that executes all .NET programs and provides modern services such as automatic memory management, security, optimization and garbage collection. 3. The .NET class library: which collects thousands of pieces of prebuilt functionality that you can snap in to your applications? These are sometimes organized into technology sets, such as ADO.NET and Windows Forms. 4. ASP.NET: the platform services that allow you to program web applications and Web Services in any .NET language, with almost any feature from the .NET class library. 5. Visual Studio .NET: an optional development tool that contains a rich set of productivity and debugging features.
VIER Page 1

Date-

Enroll No-

PRINCIPLE DESIGN FEATURES:


1. Interoperability: Because of the interaction between new and older applications required, the .NET Framework provides means to access functionality that is implemented in programs that execute outside the .NET environment. 2. Common Runtime Engine: CLR (Common language Runtime) is the virtual machine component of the .NET framework. All .NET programs execute under the supervision of the CLR.

3. Language Independence: The .NET Framework introduces a Common Type System or CTS, which defines all possible data types and programming. It supports the exchange of instances between programs written in any of the .NET languages. 4. Base Class Library: This is the part of Framework class Library that provides classes which encapsulates a number of common functions, including file reading and writing, graphic rendering, database interaction and XML document manipulation.

5. Security: .NET provides a common security model for all applications .

VIER

Page 2

Date-

Enroll No-

VERSIONS OF .NET FRAMEWORK:


Microsoft started development on the .NET Framework in the late 1990s originally under the name of Next Generation Windows Services (NGWS). By late 2000 the first beta versions of .NET 1.0 were released.

VIER

Page 3

Date-

Enroll No-

.NET Framework 1.0: This is the first release of the .NET Framework, released on 13 February 2002 and available for Windows 98, Me, NT 4.0, 2000, and XP.

.NET Framework 1.1: This is the first major .NET Framework upgrade. It is available on its own as a redistributable package or in a software development kit, and was published on April 3, 2003. It is also part of the second release of Microsoft Visual Studio .NET (released as Visual Studio .NET 2003). This is the first version of the .NET Framework to be included as part of the Windows operating system, shipping with Windows Server 2003. Changes since 1.0

Built-in support for mobile ASP.NET controls. Previously available as an add-on for .NET Framework, now part of the framework. Security changes - enable Windows Forms assemblies to execute in a semi-trusted manner from the Internet, and enable Code Access Security in ASP.NET applications. Built-in support for ODBC and Oracle databases. Previously available as an add-on for .NET Framework 1.0, now part of the framework. .NET Compact Framework - a version of the .NET Framework for small devices. Internet Protocol version 6 (IPv6) support. Numerous API changes.

.NET Framework 2.0 Released with Visual Studio 2005, Microsoft SQL Server 2005, and BizTalk 2006.

The 2.0 Redistributable Package can be downloaded for free from Microsoft, and was published on 2006-01-22. The 2.0 Software Development Kit (SDK) can be downloaded for free from Microsoft. It is included as part of Visual Studio 2005 and Microsoft SQL Server 2005. Version 2.0 is the last version with support for Windows 2000, Windows 98 and Windows Me. It shipped with Windows Server 2003 R2 (not installed by default).

Changes since 1.1


Numerous API changes. A new hosting API for native applications wishing to host an instance of the .NET runtime. The new API gives a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more (detailed
Page 4

VIER

Date-

Enroll No-

reference). It was initially developed to efficiently host the runtime in Microsoft SQL Server, which implements its own scheduler and memory manager. Full 64-bit support for both the x64 and the IA64 hardware platforms. Language support for Generics built directly into the .NET CLR. Many additional and improved ASP.NET web controls. New data controls with declarative data binding. New personalization features for ASP.NET, such as support for themes, skins and web parts. .NET Micro Framework - a version of the .NET Framework related to the Smart Personal Objects Technology initiative.

.NET Framework 3.0 .NET Framework 3.0, formerly called WinFX, includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems. It is also available for Windows XP SP2 and Windows Server 2003 as a download. There are no major architectural changes included with this release; .NET Framework 3.0 uses the Common Language Runtime of .NET Framework 2.0. Unlike the previous major .NET releases, there was no .NET Compact Framework release made as a counterpart of this version. .NET Framework 3.0 consists of four major new components:

Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies. See WPF SDK for developer articles and documentation on WPF. Windows Communication Foundation (WCF), formerly code-named Indigo; a serviceoriented messaging system which allows programs to interoperate locally or remotely similar to web services. Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows. Windows CardSpace, formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website.

VIER

Page 5

Date-

Enroll No-

.NET Framework 3.5:Version 3.5 of the .NET Framework was officially released to manufacturing (RTM) on November 19, 2007. As with .NET Framework 3.0, version 3.5 uses the CLR of version 2.0. In addition, it installs .NET Framework 2.0 SP1, which adds some methods and properties to the BCL classes in version 2.0 which are required for version 3.5 features such as Language Integrated Query (LINQ). These changes do not affect applications written for version 2.0, however. As with previous versions, a new .NET Compact Framework 3.5 was released in tandem with this update in order to provide support for additional features on Windows Mobile and Windows Embedded CE devices. The source code of the Base Class Library in this version has been partially released under Microsoft Reference License. Summary of changes in version 3.5

New language features in C# 3.0 and VB.NET 9.0 compiler Adds support for expression trees and lambda methods Extension methods Anonymous types with static type inference Language Integrated Query (LINQ) along with its various providers o LINQ to Objects o LINQ to XML o LINQ to SQL Paging support for ADO.NET ADO.NET synchronization API to synchronize local caches and server side data stores Asynchronous network I/O API Peer-to-peer networking stack, including a managed PNRP resolver Managed wrappers for WMI and Active Directory APIs Enhanced WCF and WF runtimes, which let WCF work with POX and JSON data, and also expose WF workflows as WCF services. Support for HTTP pipelining and syndication feeds. ASP.NET AJAX is included New System.CodeDom namespace

VIER

Page 6

Date-

Enroll No-

PRACTICAL: 2

AIM: Write a program to implement arithmetic calculator in console application in VB language .


Module Module1 Dim a, b, c, ans As Integer Dim s As String Sub Main() a1: Console.WriteLine("1-add" + vbNewLine + "2-sub" + vbNewLine + "3-mul" + vbNewLine + "4-div") Console.WriteLine("enter a choice") c = Console.ReadLine() Console.WriteLine("enter value of a") a = Console.ReadLine() Console.WriteLine("enter value of b") b = Console.ReadLine() Select Case c Case 1 ans = a + b Case 2 ans = a - b Case 3 ans = a * b Case 4 ans = a / b End Select Console.WriteLine("the ans" & ans) Console.WriteLine("do u want to continue??? press y") s = Console.ReadLine() If (s = "y") Then GoTo a1 Else Exit Sub End If End Sub End Module
VIER Page 7

Date-

Enroll No-

Output:-

VIER

Page 8

Date-

Enroll No-

PRACTICAL: 3

AIM: Implement calculator in window Application using GUI.


Public Class Form1 Dim a, b, c As Integer Dim op, count As Integer

Private Sub Textcal_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textcal.TextChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (Textcal.Text = "0") Then Textcal.Text = Button1.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button1.Text b = Textcal.Text Else Textcal.Text = Button1.Text b = Textcal.Text End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If (Textcal.Text = "0") Then Textcal.Text = Button2.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button2.Text b = Textcal.Text Else Textcal.Text = Button2.Text b = Textcal.Text
VIER Page 9

Date-

Enroll No-

End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If (Textcal.Text = "0") Then Textcal.Text = Button3.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button3.Text b = Textcal.Text Else Textcal.Text = Button3.Text b = Textcal.Text End If End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If (Textcal.Text = "0") Then Textcal.Text = Button4.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button4.Text b = Textcal.Text Else Textcal.Text = Button4.Text b = Textcal.Text End If End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If (Textcal.Text = "0") Then Textcal.Text = Button5.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button5.Text b = Textcal.Text Else Textcal.Text = Button5.Text b = Textcal.Text End If
VIER Page 10

Date-

Enroll No-

End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click If (Textcal.Text = "0") Then Textcal.Text = Button6.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button6.Text b = Textcal.Text Else Textcal.Text = Button6.Text b = Textcal.Text End If End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If (Textcal.Text = "0") Then Textcal.Text = Button7.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button7.Text b = Textcal.Text Else Textcal.Text = Button7.Text b = Textcal.Text End If End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click If (Textcal.Text = "0") Then Textcal.Text = Button8.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button8.Text b = Textcal.Text Else Textcal.Text = Button8.Text b = Textcal.Text End If End Sub
VIER Page 11

Date-

Enroll No-

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click If (Textcal.Text = "0") Then

Textcal.Text = Button9.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button9.Text b = Textcal.Text Else Textcal.Text = Button9.Text b = Textcal.Text End If End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click If (Textcal.Text = "0") Then Textcal.Text = Button10.Text b = Textcal.Text ElseIf (Textcal.Text <> "0") Then Textcal.Text += Button10.Text b = Textcal.Text Else Textcal.Text = Button10.Text b = Textcal.Text End If End Sub Private Sub dot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dot.Click Count = 1 If (Count = 1) Then Textcal.Text += dot.Text Else End If End Sub Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click If (op = 1) Then c=a+b
VIER Page 12

Date-

Enroll No-

Textcal.Text = c op = 0 ElseIf (op = 2) Then c=a-b Textcal.Text = c op = 0 ElseIf (op = 3) Then c=a*b Textcal.Text = c op = 0 ElseIf (op = 4) Then c=a/b Textcal.Text = c op = 0 Else End If End Sub Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click op = 1 a = Textcal.Text Textcal.Text = "0" End Sub Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click op = 2 a = Textcal.Text Textcal.Text = "0" End Sub Private Sub Mul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Mul.Click op = 3 a = Textcal.Text Textcal.Text = "0" End Sub Private Sub Div_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Div.Click op = 4 a = Textcal.Text
VIER Page 13

Date-

Enroll No-

Textcal.Text = "0" End Sub Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click Textcal.Text = "0" End Sub End Class

VIER

Page 14

Date-

Enroll No-

Output:-

VIER

Page 15

Date-

Enroll No-

PRACTICAL: 4

AIM: Write a program to implement windows application in VB.net using Object Oriented Concepts.

1. Form1.vb Public Class Form1 Private objb1 As clsBill = New clsBill() Private Rate, Subtotal As Decimal Dim str As String Public Sub LoadCity() cbocity.Items.Add("Vadodara") cbocity.Items.Add("Anand") cbocity.Items.Add("surat") cbocity.Items.Add("vapi") End Sub Public Sub LoadItem() cboItem.Items.Add("Pizza") cboItem.Items.Add("Puff") cboItem.Items.Add("Burger") End Sub Private Sub cboItem_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItem.SelectedIndexChanged If (cboItem.SelectedItem = "Pizza") Then Rate = 100 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg") ElseIf (cboItem.SelectedItem = "Puff") Then Rate = 10 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg") ElseIf (cboItem.SelectedItem = "Burger") Then Rate = 50 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg")
VIER Page 16

Date-

Enroll No-

End If PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage lblRAte.Text = Rate End Sub Private Sub badd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles badd.Click Subtotal = Rate * CDec(txtQty.Text) lblSubtotal.Text = Subtotal str = "Item Name = " + cboItem.SelectedItem.ToString() + " Rate = " + Rate.ToString() + " Quantity = " + txtQty.Text + " Subtotal = " + Subtotal.ToString() + "" lstItem.Items.Add(str) CalTotal() End Sub Public Sub CalTotal() If rdbyes.Checked = True Then objb1.Cal_Total(Subtotal, True) Else objb1.Cal_Total(Subtotal, False) End If

lbltotal.Text = objb1.Total lblVat.Text = objb1.Vat lblTAx.Text = objb1.Tax lblDPrice.Text = objb1.DiscountPrice lblFtotal.Text = objb1.FinalTotal End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load LoadCity() LoadItem() End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim s As String = lstItem.SelectedItem Dim s1(10) As String s1 = s.Split("=")
VIER Page 17

Date-

Enroll No-

Subtotal = -(CDec(s1(4))) CalTotal() lstItem.Items.Remove(lstItem.SelectedItem)

End Sub Private Sub breset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles breset.Click lbltotal.Text = 0 lblVat.Text = 0 lblTAx.Text = 0 lblDPrice.Text = 0 lblFtotal.Text = 0 lstItem.Items.Clear() End Sub End Class

2. ClsBillGeneration.vb Public Class ClsBillGeneration Private _DiscountPrice As Decimal Public Property DiscountPrice As Decimal Get Return _DiscountPrice End Get Set(ByVal value As Decimal) _DiscountPrice = value End Set End Property Protected Friend Function GetDiscount(ByRef total As Decimal, ByVal discountPer As Decimal) DiscountPrice = (total * discountPer) / 100 Return DiscountPrice End Function Protected Friend Function GetDiscount(ByRef total As Decimal) DiscountPrice = 0 Return DiscountPrice End Function End Class

VIER

Page 18

Date-

Enroll No-

3. ClsBill.vb

Public Class clsBill : Inherits ClsBillGeneration

#Region "Variable Declaration" Private _Total, _TAx, _Vat, _DiscountPrice, _FinalTotal, _DiscountPER As Decimal #End Region #Region "Property Decalration" Public Property Total As Decimal Get Return _Total

End Get Set(ByVal value As Decimal) _Total = value End Set End Property Public Property Tax As Decimal Get Return _TAx

End Get Set(ByVal value As Decimal) _TAx = value End Set End Property Public Property Vat As Decimal Get Return _Vat

End Get Set(ByVal value As Decimal) _Vat = value End Set


VIER Page 19

Date-

Enroll No-

End Property Public Property DiscountPrice As Decimal Get Return _DiscountPrice

End Get Set(ByVal value As Decimal) _DiscountPrice = value End Set End Property Public Property FinalTotal As Decimal Get Return _FinalTotal

End Get Set(ByVal value As Decimal) _FinalTotal = value End Set End Property Public Property DiscountPER As Decimal Get Return _DiscountPER

End Get Set(ByVal value As Decimal) _DiscountPER = value End Set End Property #End Region #Region "procedure Declaration" Public Sub Cal_Total(ByVal SubTotal As Decimal, ByVal IsDiscount As Boolean) Total = Total + SubTotal Vat = (Total * 10) / 100 Tax = (Vat * 5) / 100 If (IsDiscount = True) Then DiscountPrice = GetDiscount(Total, DiscountPER)
VIER Page 20

Date-

Enroll No-

Else DiscountPrice = GetDiscount(Total) End If FinalTotal = (Total - DiscountPrice) + Tax + Vat

End Sub #End Region #Region "Constructor Decalration" Public Sub New() _DiscountPER = 20 End Sub #End Region End Class

VIER

Page 21

Date-

Enroll No-

OUTPUT 1. Adding The Items

VIER

Page 22

Date-

Enroll No-

2. Deleting The Items And Updating The Final Total

VIER

Page 23

Date-

Enroll No-

3. Reset The All Values

VIER

Page 24

Date-

Enroll No-

PRACTICAL: 5

AIM: To create windows application to insert, update and delete data and bind data in .net in grid view using namespace.

Form1.vb
Imports System.Data.SqlClient Imports System.Data Imports System.Configuration

Public Class Form1 Private c As New Clsinsert() Private i As Integer Private j As Integer = 0 Private ds As DataSet Private str As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load LoadCity() BindGrid() End Sub Public Sub LoadCity() cbocity.Items.Add("Vadodara") cbocity.Items.Add("Anand") cbocity.Items.Add("surat") cbocity.Items.Add("vapi") End Sub Public Sub BindGrid() FillAllData() If (ds.Tables(0).Rows.Count > 0) Then DataGridView1.DataSource = ds.Tables(0) Else MessageBox.Show("No record found...") End If End Sub Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
VIER Page 25

Date-

Enroll No-

c.name = txtname.Text c.addr = txtadd.Text c.city = cbocity.SelectedItem c.email = txteid.Text c.pin = txtpin.Text c.phone = txtph.Text If (rdbMale.Checked = True) Then c.gen = True Else c.gen = False End If If (CheckBox1.Checked = True) Then str = "E" + ":" End If If (CheckBox2.Checked = True) Then str = str + "H" + ":" End If If (CheckBox3.Checked = True) Then str = str + "G" End If c.lang = str i = c.insert() If i = 1 Then MessageBox.Show("Record inserted Successfully") BindGrid() Else MessageBox.Show("Record not inserted Successfully") End If End Sub Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click c.name = txtname.Text i = c.delete() If i = 1 Then MessageBox.Show("Record deleted Successfully")
VIER Page 26

Date-

Enroll No-

BindGrid() Else MessageBox.Show("Record not deleted Successfully") End If

End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click FillAllData() If (ds.Tables(0).Rows.Count > 0) Then txtname.Text = ds.Tables(0).Rows(0)("Name").ToString() txtadd.Text = ds.Tables(0).Rows(0)("Address").ToString() txtpin.Text = ds.Tables(0).Rows(0)("Pin").ToString() txtph.Text = ds.Tables(0).Rows(0)("Phone").ToString() txteid.Text = ds.Tables(0).Rows(0)("Email").ToString() cbocity.SelectedItem = ds.Tables(0).Rows(0)("City").ToString() If (ds.Tables(0).Rows(0)("Gender").ToString() = True) Then rdbMale.Checked = True Else rdbFemale.Checked = True End If Else MessageBox.Show("No record found...") End If

End Sub Public Sub FillAllData() ds = New DataSet() ds = c.GetAllData() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click j = j + 1 If (j < ds.Tables(0).Rows.Count) Then txtname.Text = ds.Tables(0).Rows(j)("Name").ToString() txtadd.Text = ds.Tables(0).Rows(j)("Address").ToString() txtpin.Text = ds.Tables(0).Rows(j)("Pin").ToString() txtph.Text = ds.Tables(0).Rows(j)("Phone").ToString()
VIER Page 27

Date-

Enroll No-

txteid.Text = ds.Tables(0).Rows(j)("Email").ToString() cbocity.SelectedItem = ds.Tables(0).Rows(j)("City").ToString() If (ds.Tables(0).Rows(j)("Gender") = True) Then rdbMale.Checked = True Else rdbFemale.Checked = True End If Else MessageBox.Show("No record found...") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click FillAllData() If (ds.Tables(0).Rows.Count > 0) Then txtname.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Name").ToString() txtname.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Name").ToString() txtadd.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Address").ToString() txtpin.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Pin").ToString() txtph.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Phone").ToString() txteid.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count 1)("Email").ToString() cbocity.SelectedItem = ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("City").ToString() If (ds.Tables(0).Rows(0)("Gender") = True) Then rdbMale.Checked = True Else rdbFemale.Checked = True End If Else MessageBox.Show("No record found...") End If End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click FillAllData()
VIER Page 28

Date-

Enroll No-

j = j - 1 If (j < ds.Tables(0).Rows.Count) Then txtname.Text = ds.Tables(0).Rows(j)("Name").ToString() txtname.Text = ds.Tables(0).Rows(j)("Name").ToString() txtadd.Text = ds.Tables(0).Rows(j)("Address").ToString() txtpin.Text = ds.Tables(0).Rows(j)("Pin").ToString() txtph.Text = ds.Tables(0).Rows(j)("Phone").ToString() txteid.Text = ds.Tables(0).Rows(j)("Email").ToString() cbocity.SelectedItem = ds.Tables(0).Rows(j)("City").ToString() If (ds.Tables(0).Rows(0)("Gender") = True) Then rdbMale.Checked = True Else rdbFemale.Checked = True End If Else MessageBox.Show("No record found...") End If End Sub Private Sub bntupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntupdate.Click c.name = txtname.Text c.addr = txtadd.Text c.city = cbocity.SelectedItem c.pin = txtpin.Text

i = c.update() If i = 1 Then MessageBox.Show("Record Updated Successfully") BindGrid() Else MessageBox.Show("Record not updated Successfully") End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click txtname.Text = "" txtadd.Text = "" txteid.Text = "" txtpin.Text = ""
VIER Page 29

Date-

Enroll No-

txtph.Text = "" End Sub End Class

Clsinsert.vb

Imports System.Data Imports System.Data.OleDb Imports practical5.conn Public Class Clsinsert #Region "Generalvariable" Private c1 As New Clsconn() Private Private Private Private Private Private #End Region con As OleDbConnection = New OleDbConnection(c1.getconn) adp As New OleDbDataAdapter() ds As DataSet cmd As New OleDbCommand() qry As String i As Integer

#Region "Local Vari" Private _name As String Private _addr As String Private _city As String Private _pin As String Private _phone As String Private _email As String Private _gen As Boolean Private _lang As String #End Region #Region "property Declaration" Public Property name As String Get Return _name End Get Set(ByVal value As String) _name = value End Set
VIER Page 30

Date-

Enroll No-

End Property Public Property addr As String Get Return _addr End Get Set(ByVal value As String) _addr = value End Set End Property Public Property pin As String Get Return _pin End Get Set(ByVal value As String) _pin = value End Set End Property Public Property email As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Property phone As String Get Return _phone End Get Set(ByVal value As String) _phone = value End Set End Property Public Property gen As Boolean Get Return _gen End Get Set(ByVal value As Boolean) _gen = value End Set End Property Public Property city As String Get Return _city End Get
VIER Page 31

Date-

Enroll No-

Set(ByVal value As String) _city = value End Set End Property Public Property lang As String Get Return _lang End Get Set(ByVal value As String) _lang = value End Set End Property #End Region #Region "Method Declaration" Public Function insert() As Integer con.Open() If gen = True Then qry = "insert into tbl_reg (Name,Address,City,Pin,Email,Phone,Gender,[Language]) values ('" + name + "','" + addr + "','" + city + "'," + pin + ",'" + email + "'," + phone + ",true,'" + lang + " ') " Else qry = "insert into tbl_reg (Name,Address,City,Pin,Email,Phone,Gender,[Language]) values ('" + name + "','" + addr + "','" + city + "'," + pin + ",'" + email + "'," + phone + ",false,'" + lang + "' ) " End If cmd = New OleDbCommand(qry, con) cmd.CommandType = CommandType.Text i = cmd.ExecuteNonQuery() con.Close() Return i End Function

Public Function GetAllData() As DataSet con.Open() qry = "select * from tbl_reg" adp = New OleDbDataAdapter(qry, con) ds = New DataSet() adp.Fill(ds) con.Close() Return ds
VIER Page 32

Date-

Enroll No-

End Function Public Function update() As Integer con.Open() qry = "update tbl_reg set Address='" + addr + "',City='" + city + "',Pin=" + pin + " where Name='" + name + "' "

cmd = New OleDbCommand(qry, con) cmd.CommandType = CommandType.Text i = cmd.ExecuteNonQuery() con.Close() Return i End Function Public Function delete() As Integer con.Open() qry = "delete from tbl_reg where Name='" + name + "' " cmd = New OleDbCommand(qry, con) cmd.CommandType = CommandType.Text i = cmd.ExecuteNonQuery() con.Close() Return i End Function #End Region

End Class

Clsconn.vb
Namespace conn Public Class Clsconn #Region "var" Private constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='D:\BE\BE-7\Dot net\Practical\practical5\registration.accdb'" #End Region Public Property getconn As String Get Return constr End Get
VIER Page 33

Date-

Enroll No-

Set(ByVal value As String) constr = value End Set End Property

End Class End Namespace

VIER

Page 34

Date-

Enroll No-

Output:-

VIER

Page 35

Date-

Enroll No-

VIER

Page 36

Date-

Enroll No-

VIER

Page 37

Date-

Enroll No-

VIER

Page 38

You might also like