private void btn_login_Click_1(object sender, System.EventArgs e)
  {
   string id=idtxt.Text.Trim();
   string pwd=pwdtxt.Text.Trim();
   if(id=="")
   {
    MessageBox.Show("请输入ID号");
   }
   else
   {
    SqlConnection conn=new SqlConnection("Server=localhost;uid=sa;pwd=;database=wxj");
    string sql="select top 1 * from user_login where userid='"+id+"'";
    SqlCommand cmd=new SqlCommand(sql,conn);
    conn.Open();
    SqlDataReader usdr=cmd.ExecuteReader();
    if(usdr!=null)
    {
     if(usdr.Read())
     {
      if(usdr["userpwd"].ToString()!=pwd)
      {
       MessageBox.Show("用户名和密码不相符");
      }
      else
      {
       MessageBox.Show("登录成功");
       this.Close();
      }
     }
     usdr.Close();
    }
   }
  }
提示是“未处理的“System.Data.SqlClient.SqlException”类型的异常出现在system.data.dll中。”
其他信息:系统错误!!!!!
这只是一个简单的密码验证程序 可是就过不了。。。。

[此贴子已经被作者于2006-5-17 17:30:26编辑过]

 
											





 
	     
											
