public List <getuser> register(register us) { SqlCommand com = new SqlCommand("select_user", con); com.CommandType = CommandType.StoredProcedure; var usersList = new List <getuser> { }; con.Open(); SqlDataReader rdr = com.ExecuteReader(); var err = rdr["error"].ToString(); while (rdr.Read()) { var ss = new getuser { id = Convert.ToInt32(rdr["id"]), name = rdr["username"].ToString(), email = rdr["email"].ToString(), password = rdr["password"].ToString() }; usersList.Add(ss); } con.Close(); return(usersList); }
public List <getuser> login(user us) { SqlCommand com = new SqlCommand("Select * from [dbo].[USER] where (username='******' or email='" + us.name + "' ) and password='******'", con); var usersList = new List <getuser> { }; try { con.Open(); SqlDataReader rdr = com.ExecuteReader(); while (rdr.Read()) { var ss = new getuser { id = Convert.ToInt32(rdr["id"]), name = rdr["username"].ToString(), email = rdr["email"].ToString(), password = rdr["password"].ToString() }; usersList.Add(ss); } } catch { var ss = new getuser { id = -1, name = "not connected", password = "******" }; usersList.Add(ss); } finally { con.Close(); } return(usersList); }
public List <getuser> getUser() { SqlCommand com = new SqlCommand("select * from [dbo].[user]", con); var usersList = new List <getuser> { }; con.Open(); SqlDataReader rdr = com.ExecuteReader(); while (rdr.Read()) { var ss = new getuser { id = Convert.ToInt32(rdr["id"]), name = rdr["username"].ToString(), email = rdr["email"].ToString(), password = rdr["password"].ToString() }; usersList.Add(ss); } con.Close(); return(usersList); }