Hi, I want to create users account where user can edit his data, eg: name, email, password, login etc. I userd Forms Authentication for Login. I want to display users data from database (SQL) and edit them and save changes. Can someone help me with this problem? What is the best way to write this code?
Relocated by PIEBALDconsult.
I've tried but I'm doing something wrong. I was trying to do this with storedproceduer rearging to this article http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson07.aspx method RunStoredProcParams. I was having errors like: Object reference not set to an instance of an object, Must Declare the scalar variable userid. I've tried to solve it by declaring (Guid)(Membership.GetUser().ProviderUserKey) etc. But my biggest problem is to select current users data. Ials have tried to use my code where user role admin can edit some data like change role or block user. Method for displaying data looks like this:
private void PobierzDane()
{
using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CS"].ConnectionString))
{
string wyswietl = "SELECT [id_uzytkownika], [imie], [nazwisko], [PESEL], [email], [login]"
+ ", [haslo], [rola], [blokada] FROM Uzytkownik";
using (SqlCommand cmd = new SqlCommand())
{
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = wyswietl;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridViewKierUzytkownik.DataSource = ds;
GridViewKierUzytkownik.DataBind();
con.Close();
}
}
I was trying here to display ony one record but I couldn't.