try
                {
                    MySQLConnection MySQLConn = new MySQLConnection(new MySQLConnectionString("127.0.0.1", "abc", "root", "", 3306).AsString);                    try
                    {
                        MySQLConn.Open();
                    }
                    catch (MySQLException ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }                    MessageBox.Show("connected!");
                    String command = "SELECT * " +
                                            "From userinfo " +
                                            "Where USER_NAME = '" + textBox1.Text +
                                            "' And PASS_WORD = '" + textBox2.Text + "'";
                    MySQLCommand cmd = new MySQLCommand(command, MySQLConn);
                    MessageBox.Show(cmd.CommandText);
               
                   // int i = Convert.ToInt32(cmd.ExecuteScalar().ToString());                  MySQLDataReader reader = cmd.ExecuteReaderEx();                    //                   string name = reader.GetString(0);
                    //                   string psw = reader.GetString(1);                    //                    MessageBox.Show(name);
                    if (reader.Read())
                    {
                        MessageBox.Show("已经登陆");
                        //      MessageBox.Show("Host = {0} and User = {1}", reader.GetString(0), reader.GetString(1));
                        //          reader.Close();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("请输入正确用户名密码");
                        return;
                    }
                    MySQLConn.Close();                }
                catch (MySQLException ex)
                {
                    MessageBox.Show(ex.Message);
                }
当输入正确的用户名密码时,系统总是抱错:
日历 System.Globalization.GregorianCalendar 中不支持该字符串所表示的 DateTime。
随便输入用户名时,显示“请输入正确的用户名密码”,不报错!麻烦各位大侠,指点一下!小弟先谢了!

解决方案 »

  1.   

    从代码来看暂时看不出有什么错误,你可以试着找一下,看在你的userinfo表中是否存在哪个字段是日期类型的?
      

  2.   

    当输入正确的用户名密码时,系统总是抱错:
    日历 System.Globalization.GregorianCalendar 中不支持该字符串所表示的 DateTime。
    随便输入用户名时,显示“请输入正确的用户名密码”,不报错!
    ---------思路就是,问题出现在验证正确后的一段代码中。看看验证正确后,是不是用到了日历控件上的什么值。然后找原因。