Pertama-tama saya membuat project baru, sediakan 2 command : test koneksi, dan listview.
Di dalam module saya membuat function :
Option Explicit
Function koneksi(server As String, database As String, user As String, password As String, con As ADODB.Connection) As Boolean
On Error GoTo x
If con.State = adStateOpen Then con.Close
con.Open "Provider=SQLNCLI10;Server=" & server & ";Database=" & database & ";Trusted_COnnection=yes;encript=yes"
koneksi = True
MsgBox "koneksi sucsess"
Exit Function
x:
koneksi = False
MsgBox "koneksi gagal"
End Function
Sub isilist()
End Sub
nah didalam command test koneksi :
scripnya :
Private Sub Command1_Click()
Dim con As New ADODB.Connection
If koneksi("DIIGNASEVIIRAPC\SQLEXPRESS", "askes", "", "", con) = False Then
Unload Me
End If
End Sub
Sekian ..
Semoga bermanfaat yah :)
Maaf bila terbatas ..
0 komentar:
Posting Komentar