Minggu, 14 Oktober 2012

Penggunaan ADO untuk memindahkan data dari satu tabel ke tabel lain

Penggunaan ADO untuk memindahkan data dari satu tabel ke tabel lain


Private Sub Command1_Click()
Dim icounter As Integer
Dim dtart As Double, dfinish As Double
Dim pnlstatus As Panel
Static i As Integer
Set pnlstatus = Form1.StatusBar1.Panels(1)
dstart = Timer
Adodc1.Refresh
Adodc2.Refresh
On Error Resume Next
ProgressBar1.Visible = True
    pnlstatus.Text = "Transfering data please wait...."
    StatusBar1.Refresh
    ProgressBar1.Max = Val(Text1.Text)
For icounter = 1 To Val(Text1.Text)
    If icounter Mod 10 = 0 Then ProgressBar1.Value = icounter
Next icounter
pnlstatus.Text = "Transfer Complete...."
StatusBar1.Refresh
For i = 0 To Adodc1.Recordset.RecordCount
      Adodc2.Recordset.AddNew
      Adodc2.Recordset("EmpNum") = Adodc1.Recordset("Empnum")
      Adodc2.Recordset("EmpName") = Adodc1.Recordset("EmpName")
      Adodc1.Recordset.MoveNext
Next i
Adodc1.Refresh
Adodc2.Refresh
For i = 0 To Adodc1.Recordset.RecordCount
    Adodc1.Recordset.Delete
    Adodc1.Recordset.MoveNext
Next i
dfinish = Timer
pnlstatus.Text = "Ready..."
ProgressBar1.Value = 0
ProgressBar1.Visible = False
Command2.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Dim icounter As Integer
Dim dtart As Double, dfinish As Double
Dim pnlstatus As Panel
Static i As Integer
Set pnlstatus = Form1.StatusBar1.Panels(1)
dstart = Timer
Adodc1.Refresh
Adodc2.Refresh
On Error Resume Next
ProgressBar1.Visible = True
    pnlstatus.Text = "Returning data please wait...."
    StatusBar1.Refresh
    ProgressBar1.Max = Val(Text1.Text)
For icounter = 1 To Val(Text1.Text)
    If icounter Mod 10 = 0 Then ProgressBar1.Value = icounter
Next icounter
pnlstatus.Text = "Return Complete...."
StatusBar1.Refresh
For i = 0 To Adodc2.Recordset.RecordCount
      Adodc1.Recordset.AddNew
      Adodc1.Recordset("EmpNum") = Adodc2.Recordset("Empnum")
      Adodc1.Recordset("EmpName") = Adodc2.Recordset("EmpName")
      Adodc2.Recordset.MoveNext
Next i
Form1.Adodc1.Refresh
Form1.Adodc2.Refresh
For i = 0 To Adodc2.Recordset.RecordCount
    Adodc2.Recordset.Delete
    Adodc2.Recordset.MoveNext
Next i
dfinish = Timer
pnlstatus.Text = "Ready..."
ProgressBar1.Value = 0
ProgressBar1.Visible = False
Command2.Enabled = False
Command1.Enabled = True
End Sub
Private Sub Command3_Click()
End
End Sub

0 komentar:

Posting Komentar

 

© 2011 e - Tutorial | by Moeh Fitrah