学校のプロジェクトに取り組んでいる私は本当にあなたの助けが必要です. データを保存した後、SqlDataReaderを使用してデータを保存します(そして、sqldatareaderの結果ビューをデバッグしているときにチェックしましたが、データがいっぱいです)、すべてのデータを持つsqldatareader変数を使用しようとすると、直接空になります?? if 行に到達する前に、私の sqlreader にはすべてのデータが含まれていますが、if 行をデバッグすると、sqlreader が空であることが示されます。
class ServicesProvider
{
public static SqlConnection connection = new SqlConnection(myprovider);
public static bool LogInVerification(string NickName,string Password)
{
SqlDataReader SqlReader;
SqlCommand command;
try
{
command = new SqlCommand("Check_LogIn", connection);
command.CommandType = CommandType.StoredProcedure;
SqlParameter prm=null;
prm = new SqlParameter("@Password", SqlDbType.VarChar);
prm.Value=NickName;
prm.Direction=ParameterDirection.Input;
command.Parameters.Add(prm);
prm = new SqlParameter("@NickName", SqlDbType.VarChar);
prm.Value=Password;
prm.Direction=ParameterDirection.Input;
command.Parameters.Add(prm);
try
{
connection.Open();
SqlReader = command.ExecuteReader();
if (SqlReader["NickName"].ToString()== "1")
return true;;
}
catch (Exception ERROR)
{
Console.WriteLine(ERROR.Message);
}
}
catch (Exception error)
{
Console.WriteLine(error.Message);
}
return false;
}
}