I have created account like
User name: Admin
Password: Ad@123
but it doesn't check for capital and small letters on both user name & password.
It open with : admin
ad@123
I have created account like
User name: Admin
Password: Ad@123
but it doesn't check for capital and small letters on both user name & password.
It open with : admin
ad@123
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Feb 12, 2023, 12:41 AM EST
Hello Nuru,
please check below link, you need to use, COLLATE SQL_Latin1_General_CP1_CS_AS to match case-sensitive check,
https://www.c-sharpcorner.com/blogs/how-to-do-case-sensitive-string-match-in-sql-server1
CREATE PROCEDURE [dbo].[tblUserSelect_Authenticate] @Username nvarchar(50), @Password nvarchar(50) AS BEGIN SELECT * FROM tblUser WHERE Username = @Username AND Password = @Password COLLATE SQL_Latin1_General_CP1_CS_AS ENDNaimish MakwanaRank #324 · 7.7K reputationPosted Feb 11, 2023, 11:51 PM EST
Hello NURU,
If you want to check capital and small letter in both then you can do following
string username = txtUsername.Text; string password = txtPassword.Text; if (string.Equals(username, "admin", StringComparison.OrdinalIgnoreCase) && string.Equals(password, "password", StringComparison.OrdinalIgnoreCase)) { //Success } else { //Fail }.Or
You can convert the vallue ToLower and compare with lower case only.
Example :
string username = txtUsername.Text.ToLower(); string password = txtPassword.Text.ToLower(); if (username == "admin" && password == "ad@123") { //Success } else { //Fail }Thanks
Naimish Makwana
Vishal JoshiRank #377 · 6.7K reputationPosted Feb 11, 2023, 11:56 PM EST
Hello
You can try the below way to accomplish the task. try a case-insensitive comparison by using InvariantCultureIgnoreCase.
String userInput = "UserName"; String dbValue = "userName"; if (String.Equals(userInput, dbValue, StringComparison.InvariantCultureIgnoreCase)) { // Write a code }Thanks