Phone Book Demo (VB.net) : Phone Book « Components « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Components » Phone Book 
Phone Book Demo (VB.net)

<%--
Code revised from 

ASP.NET Tips & Techniques (Paperback)
by Greg Buczek 


# Publisher: McGraw-Hill/Osborne Media; 1st edition (May 212002)
# Language: English
# ISBN: 0072225149

--%>   
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostBack Then
        Dim DBConn as OleDbConnection
        Dim DBCommand As OleDbDataAdapter
        Dim DSPageData as New DataSet
        DBConn = New OleDbConnection_
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
            "DATA SOURCE=" _
            & Server.MapPath _
            ("PhoneDir.mdb;"))
        DBCommand = New OleDbDataAdapter _
            ("Select EmpName as [Employee Name], " _
            "Department, PhoneNumber as " _
            "[Phone Number] From Emps " _
            "Order By EmpName", DBConn)
        DBCommand.Fill(DSPageData, _
            "Employees")
        dgEmps.DataSource = _
            DSPageData.Tables("Employees").DefaultView
        dgEmps.DataBind()
        DBCommand = New OleDbDataAdapter _
            ("Select Distinct Department From Emps " _
            "Order By Department", DBConn)
        DBCommand.Fill(DSPageData, _
            "Departments")
        ddlDepartments.DataSource = _
            DSPageData.Tables("Departments").DefaultView
        ddlDepartments.DataBind()
    End If
End Sub
Sub ddl1_Changed(Sender As Object, E As EventArgs)
    Dim DBConn as OleDbConnection
    Dim DBCommand As OleDbDataAdapter
    Dim DSPageData as New DataSet
    DBConn = New OleDbConnection_
        "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
        "DATA SOURCE=" _
        & Server.MapPath _
        ("PhoneDir.mdb;"))
    DBCommand = New OleDbDataAdapter _
        ("Select EmpName as [Employee Name], " _
        "Department, PhoneNumber as " _
        "[Phone Number] From Emps " _
        "Where Department = '" _
        & ddlDepartments.SelectedItem.Text _
        "' Order By EmpName", DBConn)
    DBCommand.Fill(DSPageData, _
        "Employees")
    dgEmps.DataSource = _
        DSPageData.Tables("Employees").DefaultView
    dgEmps.DataBind()
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Phone Directory</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:label 
    id="lblMessage1" 
    font-size="12pt"
    font-bold="True"
    font-name="Lucida Console"
    text="Phone Number List"
    runat="server"
/>
<BR><BR>
<asp:datagrid
    id="dgEmps" 
    runat="server" 
    autogeneratecolumns="True"
/>
<BR><BR>
<asp:label 
    id="lblMessage2" 
    font-size="10pt"
    font-name="Lucida Console"
    text="Filter by Department"
    runat="server"
/>
<BR>
<asp:dropdownlist
    id="ddlDepartments"
    datatextfield="Department" 
    autopostback="True"
    onselectedindexchanged="ddl1_Changed"
    runat="server"
/>
</form>
</BODY>
</HTML>
           
       
PhoneDir.zip( 7 k)
Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.