Windows Mobile应用程序的用户角色!! [英] User Roles For windows mobile app!!

查看:66
本文介绍了Windows Mobile应用程序的用户角色!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows移动应用程序,我需要创建一些用户角色,具体取决于用户.我如何设置用户角色,进行这种身份验证的最佳方法是什么?我的应用程序还连接到外部sql server database.any想法,请分享!

在使用用户名和密码列创建sql表之后,我已经进行了这种身份验证,我检查它们是否存在...

I am developing a Windows mobile app,and i need to create some user roles,depending from the user.How can i set user roles,whats the best way to make this type of authentication?My app also connects to an outside sql server database.any idea,pls share!!

I have done this type of authentication,after creating a sql table with username and password colums,i chek if they exists...

namespace MobileAPPLICATION
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button_login_Click(object sender, EventArgs e)
        {
            string _connectionstring = @"Server='.\SQLEXPRESS';Initial Catalog=LOGIN;USER ID=SA;PWD=;";
            SqlConnection _connection = new SqlConnection(_connectionstring);

            if (txtpwd.Text == "")
            {
                MessageBox.Show("Password is empty!");
                txtpwd.Focus();
            }
            else
            {
                    _connection.Open();

                           
                    string _sql = "SELECT * FROM [LOGIN] where username=@username and password=@password;";
                    SqlCommand _command = new SqlCommand(_sql, _connection);
                    _command.Parameters.AddWithValue("@username", txtusername.Text);
                    _command.Parameters.AddWithValue("@password", txtpwd.Text);

                    if (_command != null)
                    {

                        //commands to go to the main menu form!
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username/Password!");
                    }
            }
        }

        private void button_reset_Click(object sender, EventArgs e)
        {
            txtusername.Text = "";
            txtpwd.Text = "";
        }
        private void txtusername_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtpwd_TextChanged(object sender, EventArgs e)
        {
           
        }

        
        
    }
}

推荐答案

为什么不使用内置在成员资格提供程序中的.NET.这里和网络上都有很多示例.

以下是一个示例的链接

http://www.4guysfromrolla.com/articles/120705-1.aspx [ ^ ]
Why not make use of the .NET built in membership providers. There are plenty of examples on here and on the web.

Below is a link to one example

http://www.4guysfromrolla.com/articles/120705-1.aspx[^]


这篇关于Windows Mobile应用程序的用户角色!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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