回 帖 发 新 帖 刷新版面

主题:SOS!HELP!!用户信息验证的问题,请各位老大看一下

[em18]俺是初学者,有段关于用户验证的代码别人的可以但我粘贴过来都不能用.我也不知道是怎么回事,单步调了一下问题初步定在loginOK=true后应该执行public bool LoginOK{}但没有执行,还望各位老大不吝赐教.感激不尽!急用!代码部分如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication3
{
    public partial class LoginForm : Form
    {
        private bool loginOK = false;
        public bool LoginOK
        {
            get
            {
                return loginOK;
            }
        }
        public LoginForm()
        {
            InitializeComponent();
        }

        private void LoginForm_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“accessDataSet.User”中。您可以根据需要移动或移除它。
            this.userTableAdapter.Fill(this.accessDataSet.User);

        }

        private  void buttonLogin_Click(object sender, EventArgs e)
        {
            AccessDataSet.UserDataTable userTable = this.userTableAdapter.GetData();

            string userName = this.textBoxUserName.Text;
            string password = this.textBoxPassword.Text;

            if ((userName != null) && (userName != ""))
            {
                if ((password != null) && (password != ""))
                {
                    string queryString = "UserID = '" + userName
                        + "' AND UserPassword = '" + password + "'";
                    DataRow[] users = userTable.Select(queryString);
                    if (users.Length > 0)
                    {
                        loginOK = true;
                    }
                    else
                    {
                        MessageBox.Show("无效的用户名或密码!");
                    }

                }
                else
                {
                    MessageBox.Show("密码不能为空!");
                }
            }
            else
            {
                MessageBox.Show("用户名不能为空!");
            }
        }
    }
}
还有一部分代码但和问题无关.各位大虾帮帮忙啦.

回复列表 (共4个回复)

沙发

有谁可以帮帮忙么?真的急用.在这俺先谢过了.

板凳

你设定loginOK为true之后没有什么执行的代码啊

3 楼

jzyray先谢了,至于后面的代码再另一个文件里,要先调用了public bool LoginOK{}之后才会调用,但现在public bool LoginOK{}就调用不了啊.各位老大帮帮忙啦.

4 楼

你的属性没有写权限,没有set

我来回复

您尚未登录,请登录后再回复。点此登录或注册