VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Validate User Login using Stored Procedures in SQL

by Joe (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 5th March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Validate User Login using Stored Procedures in SQL

Rate Validate User Login using Stored Procedures in SQL




'******************************
'**** 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


Download this snippet    Add to My Saved Code

Validate User Login using Stored Procedures in SQL Comments

No comments have been posted about Validate User Login using Stored Procedures in SQL. Why not be the first to post a comment about Validate User Login using Stored Procedures in SQL.

Post your comment

Subject:
Message:
0/1000 characters