Rabu, 22 Juli 2009

Access the Database with the same time

Have all the partners when we access the database and other users also do same? akbitanya what? Perhaps in the Client-Server architecture sometimes have access to the database by accident at the same time (same time). even world-class drivers michael summacker I even print the score, but on different data packet that is sent does not like drivers, equality can occur when we menyelect databse.


Option Explicit

Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Private Sub Form_Load()
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection

With cn
.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _
"data source=C:\oks.mdb"
.CursorLocation = adUseClient
.Open
End With
With rs
.ActiveConnection = cn
.LockType = adLockPessimistic
.Open "select * from barang"
End With
rs.MoveLast
If rs.RecordCount = 0 Then
Exit Sub
End If

If cn.BeginTrans = True Then
cn.BeginTrans
End If
rs.MoveFirst
Do Until rs.EOF
If rs("kodebarang") = "2004" Then
rs("kodebarang") = "2005"
rs.Update
End If
rs.MoveNext
Loop
If MsgBox("Apakah Anda yakin untuk menyimpan-nya?", _
vbQuestion + vbYesNo, "Konfirmasi") = vbYes Then
cn.CommitTrans
Else
cn.RollbackTrans
End If
End Sub




Tidak ada komentar:

Posting Komentar