好的,所以我一直在努力解决这个问题。我的代码中有一个“警告”-“检测到无法访问的代码”。我不知道如何解决这个问题,这就是我在这里发帖的原因。下面是代码:
public static byte Authenticate(string UserName, string Password)
{
try
{
MySqlDataAdapter DataAdapter = new MySqlDataAdapter("SELECT * FROM `Accounts` WHERE `AccountID` = '" + UserName + "'", Connection);
DataSet DSet = new DataSet();
DataAdapter.Fill(DSet, "Account");
if (DSet != null && DSet.Tables["Account"].Rows.Count > 0)
{
DataRow DR = DSet.Tables["Account"].Rows[0];
string Pass = (string)DR["Password"];
if (Pass == Password || Pass == "")
{
if (Pass == "")
{
MySqlCommand Command = new MySqlCommand("UPDATE `Accounts` SET `Password` = '" + Password + "' WHERE `AccountID` = '" + UserName + "'", Connection);
Command.ExecuteNonQuery();
}
uint LogonCount = (uint)DR["LogonCount"];
LogonCount++;
MySqlCommand Comm = new MySqlCommand("UPDATE `Accounts` SET `LogonCount` = " + LogonCount + " WHERE `AccountID` = '" + UserName + "'", Connection);
Comm.ExecuteNonQuery();
return Convert.ToByte((uint)DR["LogonType"]);
}
else
return 0;
}
else
return 0;
}
catch (Exception Exc) { General.WriteLine(Exc.ToString()); return 0; General.ServerRestart(); }
}
我不知道如何将其突出显示为红色,所以我将发布特定的行:
catch (Exception Exc) { General.WriteLine(Exc.ToString()); return 0; General.ServerRestart(); }
警告是“常规”。ServerRestart();