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

Sunday, August 7, 2011

VB-87 : Employee details

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

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


That is , Creating Database within VB Platform


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

Write a program in VB to find out details about software engineers working in a S/W company. Details are stored in a database with Emp_Id as primary key. You need to store the following information in database:
  1. Emp_ID
  2. Name
  3. Edu_Qualification
  4. Year_Of_Experience
  5. Area_Of_Specialisation

(A)Program Design : 



(B) Property(Controls Used) :
  • 5 Labels and 5 Text Boxes
  • 2 Command Buttons (Save & Exit)

(C) Attaching Code to the Object :



Public cnn As ADOdb.Connection
Public rs As ADOdb.Recordset
Dim search As String
Private Sub Command1_Click()
Call createConnection

With rs
.ActiveConnection = cnn
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.Source = "Select*From emp"
.Open

End With
rs.AddNew

rs.Fields(0) = CInt(Text1.Text)
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Text4.Text
rs.Fields(4) = Text5.Text

rs.Update
rs.Close
Call clear
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set rs = New ADOdb.Recordset
End Sub
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 & "\emp.mdb;Persist Security Info=False"
.CursorLocation = adClient
.Open
End With
End Sub
Private Sub clear()
Text1.Text = ""
Text2 = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub



(D) Output :

(May be some error if the path given is not correct..Then , we will receive an error message as "Use-Defined type not defined.".and it may point to the first line : cnn As ADOdb.Connection)

(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.

      • ====================================================================
        Back to Home   &  VB
    ==========================================================

    No comments: