如何在sqlser2008,asp.net中验证电子邮件地址 [英] How to validate Email Address in sqlser2008 ,asp.net

查看:89
本文介绍了如何在sqlser2008,asp.net中验证电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在asp.net,Sqlserver中查看@之前的电子邮件地址?



我的表4中的记录sqlserver,



id电子邮件

--------------------

1 test@test.com

2 test1@test.com

3 testr@test.com

4 common @ test.com



现在我尝试使用tests@test.com注册电子邮件ID,不需要检查域名,但我只需要@ char之前。



检查并显示消息此电子邮件ID在asp.net中可用。



请让我知道。



提前谢谢。

Hi,
How to check Email Address of before @ in asp.net,Sqlserver?

My Table 4 records available in sqlserver,

id Email
--------------------
1 test@test.com
2 test1@test.com
3 testr@test.com
4 common@test.com

Now I try to register Email ID with "tests@test.com" and no need to check domain name but i need only before @ char.

Check and display message "This Email id simillarly available in asp.net" .

Please let me know .

Thanks in advance.

推荐答案

你可以使用带有CharIndex函数的子串函数。



类似



You can Use a Substring function with a CharIndex function .

Something like

SELECT SUBSTRING(@email, 1, CHARINDEX('@', @email) - 1)// Need to modify accordingly





并在返回的S上执行相等ubstring(即。 @字符前面的名称)



And perform an equality on the returned Substring ( ie. name before the @ character )


最好采取整个字符串并直接检查。查询看起来像......

Better to take the whole string and check directly. The query would look like...
SELECT count(id)
FROM Users
WHERE Email = @InputEmail



使用 SQLParameter Class @InputEmail 值a> [ ^ ]。如果 count 大于0,则记录存在。



否则你需要拆分字符串并将其与电子邮件列进行比较。


Provide the @InputEmail value using SQLParameter Class[^]. If count is greater than 0, then record exists.

Otherwise you need to Split the string and compare it with Email Column.


这篇关于如何在sqlser2008,asp.net中验证电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆