contoh. biar tidak lupa terus:
di gunakan misal bila hasil count > 0 akan ada message box dan
bila count <= 0 akan ada message box
---------------------------------------------------
Private Sub Command11_Click()
Dim sql As String
Dim yyn As String
sql = "select count(id)y from tabel where kolom > '2011-01-12' "
Set rs = db.Execute(sql)
yy = rs!y
If ap > "0" Then
MsgBox "lebih dari nol!"
Else
MsgBox "nol ATAU kurang !"
End If
End Sub
---------------------------------
untuk koneksi, buat di form modul:
Option Explicit
Public db As New Connection
Public rs As New Recordset
Public sql As String
Public Function Koneksi_Database() As Boolean
'On Error GoTo pesan
If db.State = adStateOpen Then
db.Close
End If
db.Open "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;" & _
"User ID=sa;" & _
"Password=passku;" & _
"Initial Catalog=databaseku;" & _
"Data Source=serverku"
db.CursorLocation = adUseClient
Koneksi_Database = True
Exit Function
'pesan:
' Koneksi_Database = False
' MsgBox "Koneksi ke server tidak berhasil !!!", 16, "ERROR"
End
End Function
Saturday, March 12, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment