返回成功
Dim user = "ravi"
Dim pass = "admin"
objcmd.CommandText = "Select * from ADMIN_INFO where ADMIN_ID='" & user & "' and ADMIN_PASS='" & pass & "'"
返回成功
Dim user = "ravi"
Dim pass = "ADMIN"
objcmd.CommandText = "Select * from ADMIN_INFO where ADMIN_ID='" & user & "' and ADMIN_PASS='" & pass & "'"
执行查询后,两者都返回成功,而表中只有ravi
和admin
可用。那么,我该如何检查区分大小写。需要帮助!!
答案 0 :(得分:2)
CREATE TABLE #temp
(
Password Varchar(2)
)
insert into #temp values('a')
select Password from #temp Where Password COLLATE Latin1_general_CS_AS = 'A'
select Password from #temp Where Password COLLATE Latin1_general_CS_AS = 'a'
select Password from #temp Where cast(Password as varbinary(2)) = cast('A' as varbinary(15))
select Password from #temp Where cast(Password as varbinary(2)) = cast('a' as varbinary(15))
drop table #temp
答案 1 :(得分:2)
本文可能会对您有所帮助:Case sensitive search in SQL Server queries。但是,通常不能以纯文本格式保存密码。
此外,您可以从数据库中选择admin行,然后在.Net端进行密码比较,默认情况下比较区分大小写。
bool result = string1.Equals(string2); //this is case sensitive unless you specify otherwise