c/s架构 mysql数据库   局域网内 winforms登陆执行MySQLDataReader DBReader = commn.ExecuteReaderEx(); 
报:System.ArgumentException: The structure must not be a value class.
Parameter name: structurestring sql = "select 操作员密码  from operatorinfo where 操作员代码 ='" + userlogin + "'";
                MySQLConnection conn = null;
                conn = new MySQLConnection(new MySQLConnectionString("220.34.182.226", "db32", "root", "").AsString);
                conn.Open();
                MySQLCommand commn = new MySQLCommand(sql, conn);
                commn.ExecuteNonQuery();
                MySQLDataReader DBReader = commn.ExecuteReaderEx();
                MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn);
                DataSet ds = new DataSet();
                mda.Fill(ds, "table1");
                if (DBReader.Read())
                {
                    if (psdlogin == DBReader["操作员密码"].ToString().Trim())
                    {
                        this.Hide();
                        LoginForm lg = new LoginForm();
                        lg.Show();
                    }
                    else
                    {
                        MessageBox.Show("  操作员密码不正确!  ", "系统提示");
                        conn.Close();
                    }
                }
                else
                {
                    MessageBox.Show("  没有此操作员,请重新输入!  ", "系统提示");
                }
                conn.Close();
                DBReader.Close();    
         

解决方案 »

  1.   

    PS:另外,建议楼主写sql不要用这种拼接的方式,尽量使用parameters的方式。这样拼接sql很容易被sql注入
      

  2.   

    又看了看代码,既然楼主用的dataReader,那么下面的代码貌似是多余的,没有起到作用:MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn); 
                    DataSet ds = new DataSet(); 
                    mda.Fill(ds, "table1"); 
      

  3.   

      if (psdlogin == DBReader["操作员密码"].Value.ToString().Trim()) 
    {
    ...
    }试试这个
      

  4.   

    MySql.Data.MySqlClient;MySqlConnection con = new MySqlConnection("server=127.0.0.1;user id=root; password=; database=DB;");用这种方式试试,前提要下载MySql.Data.dll