System. A NotSupportedException: "No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the encoding. RegisterProvider method."
String connStr="data source=localhost; The database=mmorpg; User id=root; Password=113432; Pooling=false; Charset=utf8; ";
Console. WriteLine (" please enter the user name: ");
String uname=Console. ReadLine ();
Console. WriteLine (" please enter the password: ");
String upwd=Console. ReadLine ();
Using (MySqlConnection conn=new MySqlConnection (connStr))//create a connection object
{
String SQL="select upwd from users1 where uname=@ the name";
MySqlParameter pName=new MySqlParameter (" @ the name, "uname);
MySqlCommand CMD=new MySqlCommand (SQL, conn);//for a query command and the connection object creation object
CMD. The Parameters. The Add (pName);//is equal to the CMD. The Parameters. The Add (new MySqlParameter (" @ the name, "uname));
conn.Open();
The object upwd2=CMD. ExecuteScalar ();//not sure to return to the first line of the type of the first column with the object so the class definition
If (upwd2==null)
{
Console. WriteLine (" the user name wrong!" );
}
The else
{
If (upwd2. ToString (). The Equals (upwd))//whether upwd2 and upwd equality Equals two values are equal
{
Console. WriteLine (" login successful!" );
}
The else
{
Console. WriteLine (" password error!" );
}
}
}
CodePudding user response:
No data can be used in the code 1252, the relevant definition of custom code information, please see the code document provider,Why is the connection times the wrong? Don't is a character set statement file is missing? But utf8 is built-in
CodePudding user response:
This is similar toCodePudding user response:
Pooling=false; Charset=utf8; This went to try itCodePudding user response:
To ask!!!!!! The building Lord, please now solved not ~ ~!!CodePudding user response:
Haven't been to, can try to debug,