by Vb Code (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 11th August 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Add Record to database
Dim db As Database, Table As Recordset, KiraRekod As Recordset, Total As Integer
Set db = Workspaces(0).OpenDatabase(App.Path & “\daftar.mdb”)
Set Table = db.OpenRecordset(”pendaftaran”, dbOpenDynaset)
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
Text4.Text = “”
Table.AddNew
End Sub
Private Sub cmdsubmit_Click()
simpanrekod
senaraicustomer
End Sub
Sub simpanrekod()
Dim db As Database, Table As Recordset, KiraTable As Recordset
Set db = Workspaces(0).OpenDatabase(App.Path & “\daftar.mdb”)
Set Table = db.OpenRecordset(”pendaftaran”, dbOpenDynaset)
Set KiraTable = db.OpenRecordset(”pendaftaran”)
Table.AddNew
Table(”Name”) = Text1.Text
Table(”User Login”) = Text2.Text
Table(”Password”) = Text3.Text
Table(”Email”) = Text4.Text
Table.Update
End Sub
Private Sub Command1_Click()
Text1.Text = “”
End Sub
Private Sub Command2_Click()
Text2.Text = “”
End Sub
Private Sub Command3_Click()
Text3.Text = “”
End Sub
Private Sub Command4_Click()
Text4.Text = “”
End Sub
Private Sub Command5_Click()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
Text4.Text = “”
End Sub
Private Sub Form_Load()
Dim db As Database, Table As Recordset, KiraRekod As Recordset, Total As Integer
Set db = Workspaces(0).OpenDatabase(App.Path & “\daftar.mdb”)
Set Table = db.OpenRecordset(”pendaftaran”, dbOpenDynaset)
Set KiraRekod = db.OpenRecordset(”pendaftaran”)
senaraicustomer
End Sub
Sub senaraicustomer()
Dim db As Database, Table As Recordset, KiraRekod As Recordset, Total As Integer
Set db = Workspaces(0).OpenDatabase(App.Path & “\daftar.mdb”)
Set Table = db.OpenRecordset(”pendaftaran”, dbOpenDynaset)
Set KiraRekod = db.OpenRecordset(”pendaftaran”)
If Table.RecordCount = 0 Then
Exit Sub
Else
End If
List1.Clear
Table.MoveFirst
While Not Table.EOF
List1.AddItem Table(”Name”)
Table.MoveNext
Wend
End Sub