Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am writen Stored Procedure. but after login not open other Page.

What I have tried:

CREATE PROCEDURE usp_Users_VerifyingLogDetails
(
		@UserName NVARCHAR(50),
		@PassWord NVARCHAR(50)
)

AS

BEGIN

SELECT * FROM Users Where [UserName] = @UserName AND [Password] = @PassWord AND

IsActive = 1
END



using (SqlCommand cmd = new SqlCommand("usp_Users_VerifyingLogDetails", con))
                   {
                       cmd.CommandType = CommandType.StoredProcedure;

                       cmd.Parameters.AddWithValue("@UserName", txtLogUserName.Text.Trim());
                       cmd.Parameters.AddWithValue("@PassWord", SecureData.EncryptData(txtLogPassword.Text.Trim()));

                       if (con.State != ConnectionState.Open)
                          con.Open();

                       DataTable dtRole = new DataTable();
                       SqlDataReader sdr = cmd.ExecuteReader();
                       if (sdr.HasRows)
                       {
                           dtRole.Load(sdr);
                           DashboardForm dbf = new DashboardForm();
                           dbf.ShowDialog();
                       }
                       else
                       {
                           MessageBox.Show("User Name and Password Not Matched", "Authontication Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
                       }
                   }
Posted
Updated 23-Jan-22 5:51am
v8
Comments
Richard Deeming 24-Jan-22 7:09am    
Removing the content of your question after it has been answered is extremely rude.

I have reverted your destructive edit.

1 solution

Values in table with bit datatype will store as 1 or 0 and on retrieval you can get with the CASE statement. Query is written below:

SELECT CASE WHEN [IsActive] = 1 THEN 'TRUE' ELSE 'FALSE' END [IsActive] 
FROM [dbo].[Users]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900