大家好,我的数据库有问题,我为网站中的用户创建了数据库信息的EditInfo html页面... Now its looking like that
它显示已登录用户的信息,他可以将其更改为他想要的任何内容... 但是它制造问题... 它不允许我更新信息...
此处的代码:
protected void Page_Load(object sender, EventArgs e)
{
string UserName;
if (Session["User"] == null)
{
Response.Redirect("Home.aspx");
}
if ((Session["AdminMode"] == "1") || (Session["AdminMode"] == "2"))
UserName = Session["AdminEditUser"].ToString();
else
UserName = Session["User"].ToString();
if (!IsPostBack)
{
int i, j;
string birthDate;
string connectionStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\WebSites\MyWebsite\App_Data\DataBase.mdb;Persist Security Info=True";
OleDbConnection connectObj = new OleDbConnection(connectionStr);
string mySql = "SELECT * from Users WHERE UserName= '" + UserName + "'";
OleDbDataAdapter dataAdapt = new OleDbDataAdapter(mySql, connectObj);
DataSet ds = new DataSet();
dataAdapt.Fill(ds, "Users");
DataRow row = ds.Tables["Users"].Rows[0];
AccountText.Text = UserName.ToString();
pass.Text = row[2].ToString();
passchecker.Text = row[2].ToString();
firstname.Text = row[3].ToString();
lastname.Text = row[4].ToString();
MyEmail.Text = row[5].ToString();
PlaceList.Text = row[6].ToString();
}
}
代码的继续:
protected void EditClick_Click(object sender, EventArgs e)
{
string eMailAvailable = MyEmail.Text;
string usercheck = users.IsEmailBelong(eMailAvailable);
bool eMailCheck = users.IsEmailExist(eMailAvailable);
if (eMailCheck == true)
{
if (usercheck == UserName)
{
IsEmail.Text = "";
MyEmail.BackColor = System.Drawing.Color.White;
}
else
{
IsEmail.Text = "";
MyEmail.BackColor = System.Drawing.Color.IndianRed;
}
}
else
{
MyEmail.BackColor = System.Drawing.Color.White;
}
if (MyEmail.Text == "")
{
int i;
string userName = UserName;
string Password = pass.Text;
string firstName = firstname.Text;
string lastName = lastname.Text;
string eMail = MyEmail.Text;
string cityID = PlaceList.Text;
bool result = users.EditUser(userName, Password, firstName, lastName, eMail, cityID);
if (result == true)
{
Response.Redirect("Home.aspx");
}
}
}
公共字符串UserName {get;组; }}
请帮助我:(