contoh OpenDB dan CloseDB ke SQLServer 2000

Public Function OpenDB() As Boolean
Dim isOpen      As Boolean
Dim ANS         As VbMsgBoxResult
isOpen = False
On Error GoTo err
Do Until isOpen = True
CN.Open “Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBContoh;Data Source=(local)”
isOpen = True
Loop
OpenDB = isOpen
Exit Function
err:
ANS = MsgBox(“Error # ” & err.Number & vbCrLf & “Description: ” & err.Description, vbCritical + vbRetryCancel)
If ANS = vbCancel Then
OpenDB = False
ElseIf ANS = vbRetry Then
Resume
End If
End Function

Public Sub CloseDB()
‘Close the connection
CN.Close
Set CN = Nothing
End Sub

One thought on “contoh OpenDB dan CloseDB ke SQLServer 2000

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