22. Write a VB program to store the details of players into the database and display that details using ADODC. (Don’t use Standard Control)


Dim C As New Connection
Dim R As New Recordset
Dim S As String
Private Sub cmdAdd_Click()
txtPcode.Text = “”
txtPname.Text = “”
txtPaddr.Text = “”
txtNOM.Text = “”

txtPcode.SetFocus
End Sub
Private Sub cmdNext_Click()
R.MoveNext
If Not R.EOF Then
txtPcode.Text = R.Fields(0).Value
txtPname.Text = R.Fields(1).Value
txtPaddr.Text = R.Fields(2).Value
txtNOM.Text = R.Fields(3).Value
Else
MsgBox “No More Records!”, vbInformation, “Player”
End If
End Sub
Private Sub cmdPrev_Click()
R.MovePrevious
If Not R.BOF Then
txtPcode.Text = R.Fields(0).Value
txtPname.Text = R.Fields(1).Value
txtPaddr.Text = R.Fields(2).Value
txtNOM.Text = R.Fields(3).Value
Else
MsgBox “No More Records!”, vbInformation, “Player”
End If
End Sub
Private Sub cmdSave_Click()
R.Close
S = “Insert Into tblPlayer Values(” & Val(txtPcode.Text) & “,'” & txtPname.Text & “‘,'” & txtPaddr.Text & “‘, ‘” & Val(txtNOM.Text) & “‘)”
R.Open S, C, adOpenDynamic, adLockOptimistic
S = “Select * From tblPlayer”
R.Open S, C, adOpenDynamic, adLockOptimistic
If Not R.BOF And Not R.EOF Then
R.MoveFirst
txtPcode.Text = R.Fields(0).Value
txtPname.Text = R.Fields(1).Value
txtPaddr.Text = R.Fields(2).Value
txtNOM.Text = R.Fields(3).Value
End If
MsgBox “Player record Added Successfully!”, vbInformation, “Player”
End Sub
Private Sub Form_Load()
S = “Select * From tblPlayer”
C.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VBSlipSol\Slip22\Ques-2\player.mdb;Persist Security Info=False”
R.Open S, C, adOpenDynamic, adLockOptimistic

If Not R.BOF And Not R.EOF Then
R.MoveFirst
txtPcode.Text = R.Fields(0).Value
txtPname.Text = R.Fields(1).Value
txtPaddr.Text = R.Fields(2).Value
txtNOM.Text = R.Fields(3).Value
End If
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s