Validate User Login using Stored Procedures in SQL
Validate User Login using Stored Procedures in SQL
Rate Validate User Login using Stored Procedures in SQL
(2(2 Vote))
'******************************
'**** Use this in a Module ****
'******************************
Public DB as New ADODB.Connection
Public RS as New ADODB.Recordset
Public QY as New ADODB.Command
Function Validate(UserName as String, Password as string,RS as ADODB.Recordset)
'-- Open a connection to SQL database
ConnectionString = "Provider= "Microsoft OLE DB Provider for SQL Server";Data Provider = "SQLOLEDB";Driver = " SQL Server" _
;Server=" & "YOUR SERVER NAME" & ";uid="sa";pwd="";Database="YOUR DATABASE"
'-- Open a connection to SQL database.
Set DB = New ADODB.Connection
DB.CursorLocation = adUseClient
DB.ConnectionTimeout = 60
DB.ConnectionString = ConnectionString
DB.Open
Set DB = QY.ActiveConnection
QY.CommandType = adCmdStoredProc
QY.CommandText = "usp_UserSecurity"
QY.Parameters.Refresh
QY.Parameters("@UserName") = UserName
QY.Parameters("@Password") = Password
Set RS = QY.Execute
'*********************************
'--User this code for the form
'--Add two text boxes and a button
'--text1 and text2
'*********************************
Private Sub Command1_Click()
Validate text1.text,text2.text,RS
If Not RS.EOF Then
msgbox "Successfull!!!"
Else
msgbox "Not Successfull"
End IF
End Sub
'***************************************************
'--Here is the code to make the stored procedures!!!
'--Make sure you have a table in SQL named "Security"
'--with Columns "UserName" and "Password"
'--You might want to enter a user name and password
'--in there to test with!!!
'***************************************************
CREATE PROCEDURE dbo.usp_UserSecurity
@UserName as varchar(50),
@Password as varchar(50)
AS
Select * from Security
Where UserName = @UserName and Password = @Password
GO
Validate User Login using Stored Procedures in SQL Comments
No comments yet — be the first to post one!
Post a Comment