Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, August 4, 2011

VB-80 : Select a detail from the given list

==================================================================================

Before going to do any Database Program ,Click here to  understand Database Concepts thoroughly.


That is , Creating Database within VB Platform


==================================================================================

Write a VB program that will find out different details about a person stored in your database with name as a key. You need to store following information about each person:
<Name.Phone,Mobile,Home_address,Office_address and email>
User should give the name of person and what information s/he want to select from the detail.
The user interface of the application should look like the following figure :



Name



Find What




Result





Cancel

Find


(A)Program Design : 



(B) Property(Controls Used) :

  • 3 Labels
  • 3 Text Boxes
  • 2 Command Buttons


(C) Attaching Code to the Object :

Public cnn As ADODB.Connection
Public rs As ADODB.Recordset
Dim search As String

Private Sub CreateConnection()
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\User.mdb;Persist Security Info=False"
.CursorLocation = adUseClient
.Open
End With
End Sub
Private Sub Command1_Click()
Call CreateConnection
With rs
.ActiveConnection = cnn
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.Source = "Select*From UserDetails where Name=" & Text1.Text & ""
.Open
End With
rs.MoveFirst
search = Text2.Text
If search = "Name" Then
Text3.Text = rs.Fields("Name")
Else
If search = "Telephone No" Then
Text3.Text = rs.Fields("Phone")
Else
If search = "Mobile No" Then
Text3.Text = rs.Fields("Mobile")
Else
If search = "Home Address" Then
Text3.Text = rs.Fields("Home Address")
Else
If search = "Office Address" Then
Text3.Text = rs.Fields("Office Address")
Else
If search = "Email" Then
Text3.Text = rs.Fields("Email")
End If
End If
End If
End If
End If
End If
rs.Close
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set rs = New ADODB.Recordset
End Sub




(E) Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post..


====================================================================
=========================================================