数据库链接是用dataset链接access的,table 只有帐户(name)和密码(password). 就是读不出来。。
        private bool ValidateNow(string un, string pwd)
        {
            foreach (DataRow dr in tableDataSet.Tables["table"].Rows)
            {
                string oun = dr["name"].ToString();
                string opwd = dr["password"].ToString();
                if (oun == un && opwd == pwd)
                    return true;
            }
            return false;
        }
        private void button1_Click(object sender, EventArgs e) {
            if (ValidateNow(textBox1.Text, textBox2.Text)) {
                MessageBox.Show("成功");
            } else {
                MessageBox.Show("失败");
                Application.Exit();
            }
        }    }

解决方案 »

  1.   

    是失败阿 大哥   就是提取提取数据库字段的值都是null要是语句有问题的话  。能不能给个范本!!!!感激不尽!!!
      

  2.   

    这应该是从数据库查询DataSet就已经错了
      

  3.   

    你的帐户(name)和密码(password)和Access的关键字有冲突,建议如果写查询语句的时候如下即可SQL:
    select [name], [password] from yourTable
      

  4.   

    检查一下传来的string un, string pwd
    msgshow出来看一下,比如un或pwd是不是多了空格.
      

  5.   

    不要用Access的关键字..
    解决方法如Knight94所说..这样的问题第一次遇到确实会有点晕..^^
      

  6.   

    把name和password换成其它的字段
      

  7.   

    你看下你的数据库连接打开了没
    connect.open()
    有没有这句
      

  8.   

    写个伪代码共楼主一看:OleDbConnection _conn = new OleDbConnection( "连接字符串" );
    _conn.Open();
    string strSQL = "select [name],[password] from Table"
    OleDbCommand _comm = new OleDbCommand( strSQL, _conn);
    DataTable dtDATA = new DataTable();
    try
    {
       OleDbDataAdapter da = new OleDbDataAdapter();
       da.SelectCommand = _comm;
       da.Fill( dtDATA );
    }
    catch( Exception Message )
    {
       抛出异常;
    }你可以先绑到DataGrid中看是否成功,来测试一下
    DataGrid.DataSource = dtDATA;
    DataGrid.DataBind();
      

  9.   

    Access数据库的关键字问题第一次碰到确实比较郁闷.