如何在C#和数据库中创建登录页面是sqlserver 2005 [英] How to create a login page in C# and database is sqlserver 2005

查看:95
本文介绍了如何在C#和数据库中创建登录页面是sqlserver 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

是Windows应用程序的新功能.

很困惑,无法在c#中创建登录页面.

我有用户名-文本框
密码-文本框

登录


请你能建议我..并详细解释一下.


谢谢,

Dear Sir,

am new to Windows Application.

am confused to create login page in c#.

i have Usename - Textbox
Password - Textbox

Login


Please can u suggest me..and explain me in detail.


Thanks,

推荐答案

如果这是Windows应用程序,则不要使用页面"一词,而应使用表单". 页面"表示涉及一个网站,而Windows应用程序则不是这种情况.

首先要做的是创建数据库表:
If this is a windows application, then don''t use the term "page" - use "form" instead. "Page" implies a website is involved, which is not the case for windows applications.

The first thing to do is create a database table:
ColumnName   Type
ID           Varies - some like integer, with identity set on. Personally, I prefer GUID.
Username     NVARCHAR - maximum length will depend on you, but 256 is a fair compromise.
Password     VARBINARY(64)



您可能需要其他列.
然后,您需要制作一个带有两个文本框的表单:tbUserName和tbPassword-后者应将UseSystemPasswordChar属性设置为true.它还需要两个按钮:确定"和取消".
然后添加两个公共属性:



You may need other columns.
You will then need to make a form, with two text boxes: tbUserName and tbPassword - the latter should have the UseSystemPasswordChar property set to true. It will also need two buttons: OK and Cancel.
Then add two public properties:

public string UserName
   {
   get { return tbUserName.Text; }
   set { tbUserName.Text = value; }
   }
public byte[] Password
   {
   get { return GetSHA1(UserName, tbPassword.Text); }
   }

,您将在此提示中找到方法GetSHA1:密码存储: [ ^ ]以及使用原因的说明.

当用户单击确定"按钮时,请对照数据库中存储的用户名和密码进行检查:我假设您知道如何从SQL中获取内容.同样,技巧中提供了一种比较它们的方法.

您还需要添加其他两种形式:创建用户,更改密码,丢失密码,删除用户是最常见的-但是,如果您能完成上述工作,它们应该很简单.

You will find the Method GetSHA1 in this Tip: Password Storage: How to do it.[^] along with an explanation of why to use it.

When the user clicks the OK button, check the username and password against those stored in your DB: I assume you know how to fetch things from SQL. Again, there is a method in the Tip for comparing them.

You will need to add a couple of other forms as well: create user, change password, lost password, delete user are the most common - but if you get the above working they should be pretty easy.


如果您是c#.net的入门者,那么我认为dis代码非常适合使用utry this ||
If you are a starter in c#.net then i think dis code is perfectly suitable for utry this|| login using c#.net


这篇关于如何在C#和数据库中创建登录页面是sqlserver 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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