При чтении данных с базы данных выдало ошибку:
В переменные значения почему то не записались(везде null).
Код:
public static void Online_Authorize(out List<User> user_list, User user)
{
user_list = new List<User>();
string ConnectionSting = @"Data Source=.\MSSQLSERVER1;Initial Catalog=OrginizerDB;Integrated Security=True";
string CommandText = "SELECT * FROM Users";
try
{
using (SqlConnection connection = new SqlConnection(ConnectionSting))
{
connection.Open();
SqlCommand cmd = new SqlCommand(CommandText,connection);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
Parse(reader, out user_list);
}
}
}
AuthorizeM(user_list, user);
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}
static void Parse(SqlDataReader reader, out List<User> user_list)
{
user_list = new List<User>();
for (int i = 0;i< reader.FieldCount;i++)
{
string[]Name = reader["Name"] as string[];
string[]Email = reader["Email"] as string[];
string[]Password = reader["Password"] as string[];
User user = new User();
user.name = Name[i];
user.email = Email[i];
user.password = Password[i];
user.islocal = false;
user_list.Add(user);
}
}
Сама таблица:
Помогите.