如何显示数据库中已有用户? [英] How to show User Already Exists in DATABASE ?

查看:124
本文介绍了如何显示数据库中已有用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

祝你有美好的一天 !!我的项目基于Asp.net,c#,SqlServer2005.

我有注册表,我有字段,

名字,姓氏,用户名,密码等.

因此,当用户填写此表格时,即输入用户名.它应该自动检查该用户名是否存在.当用户在文本框中输入内容时,应检查数据库并在标签中显示一条消息.

如果它已经存在于数据库中,则它必须显示已经存在(已选择某人,请尝试另一个)

请给我解决这个问题的好方法.

谢谢.

Dear All ,

Have a good Day !! My project is based upon Asp.net,c#,SqlServer 2005.

I have Registration form i which i have Fields as,

FirstName, LastName,UserName, Password etc etc.

So, when the user fill ups this Form, when he is entering Username. It should check automatically that this username Exists or not. when user is entering in textbox , it should check the database.and displays a message in label.

if its already exists in Database, it must show already exists(Someone already choosed, Try another)

Please give me good solution for this problem.

Thanks.

推荐答案

有什么努力吗?这样做已经有很多次了,互联网上有很多这样的例子.
Microsoft甚至将Login Control附带在其中,这样您就不必再做一遍了.查看以下链接:

http://msdn.microsoft.com/en-us/library/ms178329.aspx [ ^ ]

http://www.asp.net/web-forms/tutorials/security/membership/creating-user-accounts-cs [ ^ ]

http://geekswithblogs.net/dotNETvinz/archive/2009/04/30/creating-a-simple-registration-form-in-asp.net.aspx [
Any efforts? This has been do so many times and internet is full of examples of it.
Microsoft even ships the Login Control with so that you don''t have do it all over again. Look at the following links:

http://msdn.microsoft.com/en-us/library/ms178329.aspx[^]

http://www.asp.net/web-forms/tutorials/security/membership/creating-user-accounts-cs[^]

http://geekswithblogs.net/dotNETvinz/archive/2009/04/30/creating-a-simple-registration-form-in-asp.net.aspx[^]


Plz通过此链接.单击按钮即可进行Web服务调用.而是在文本框onblur事件中使用它.
如何从客户端调用Web服务使用ASP.NET AJAX的JavaScript
Plz go through this link. Here webservice call is on button click. Instead use it in textbox onblur event.
How to call a Web Service from client-side JavaScript using ASP.NET AJAX


检查用户是否在Db中

从用户"中选择Usenname;
然后与与用户比较"输入带有Db UserName的用户名
像这样
Checking User is present in Db or Not

Select Usenname from Users ;
Then Compare With User entered Username with Db UserName
Like This
Sqlconnection con=new sqlconnection(Your connection string);
Sqldataadapter da=new Sqldataadapter("Select Usenname from Users",con);
dataset ds=new dataset();
if(textbox1.text==ds.tables[0].rows[0][0].tostring())
{
lblmsg.Text="Please Choose another User"
}
else
{
//Proceed

}


这篇关于如何显示数据库中已有用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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