Dear all,
Ak ada kesulitan tentang koneksi database SQL untuk login. contoh code
koneksi access seprti ini :
Private Sub CmdLog_Click()
Dim db_file As String
Dim statement As String
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
db_file = App.Path & "\Master1.mdb"
Set cnn = New ADODB.Connection
cnn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
cnn.Open
statement = "SELECT COUNT (*) FROM Users WHERE " & _
"UserName='" & Replace(Text1.text, "'", "''") & "' AND " & _
"Password='" & Replace(Text2.text, "'", "''") & "'"
Set rs = cnn.Execute(statement)
If CLng(rs.Fields(0)) < 1 Then
MsgBox "Invalid your user name or password!", 0, "Warning"
Text1.text = ""
Text2.text = ""
Text1.SetFocus
Else
Txt = "" & " " & UCase$(Text1.text) & ""
MsgBox "Welcome to CELLNET Application", vbOKOnly + vbExclamation,
"Security Login"
If Text1.text = "admin" Then
FrmMain.mEdit = True
FrmMain.mSystem = True
FrmMain.mView = True
FrmMain.mExit = True
Else
FrmMain.mEdit = False
FrmMain.mSystem = False
FrmMain.mView = True
FrmMain.mExit = True
End If
FrmMain.StatusBar1.Panels(1).text = "User : " & FrmLog.Text1
Text1.text = ""
Text2.text = ""
Text1.SetFocus
Me.Hide
End If
rs.Close
cnn.Close
End Sub
Private Sub CmdOut_Click()
End
End Sub
Bagaimana cara mengubah koneksinya dari sebelumnya access ke SQL.
Atas perhatian dan bantuan dari teman2 semuanya saya mengucapkan terima kasih.
---------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel
bargains.