|
 |
|
ช่วยแก้ไขปัญหา เกี่ยวกับการ Update ข้อมูล หนอยครับ มันไม่ Update ให้อะครับ |
|
 |
|
|
 |
 |
|
ผมได้ลองทำตาม เนื้อหา จาก
https://www.thaicreate.com/free-web-script/asp.net-register-login-reset-password-update-profile.html
ก็ได้ มาจนถึง ฟอร์ม Update ข้อมูลสมาชิกครับ
พอแก้ไขข้อมูลแล้ว กด update มันไม่ update ให้อะครับ .. ไม่มี Error
ตรวจ ดูแล้วก็ไม่มีอะไรผิดพลาดนะครับ ยังไง ช่วยดูให้ทีครับ
Code (C#)
protected void send_Update1_Click(object sender, EventArgs e)
{
strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
Conn = new SqlConnection(strConnection);
Conn.Open();
sqlcmd.Connection = Conn;
strSQL = new StringBuilder();
strSQL.Append(" SELECT COUNT(*) FROM Member ");
strSQL.Append(" WHERE Email = @Email AND Username <> @Username");
sqlcmd = new SqlCommand(strSQL.ToString(), Conn);
sqlcmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = this.txtEmail.Text;
sqlcmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = Session["strUsername"];
intCount = (int)sqlcmd.ExecuteScalar();
if (intCount >= 1)
{
this.lblMsg.ForeColor = System.Drawing.Color.Red;
this.lblMsg.Text = "Email already exists!!";
return;
}
//'*** Update Profile ***//
strSQL = new StringBuilder();
strSQL.Append(" UPDATE Member ");
strSQL.Append(" SET Password = @Password ");
strSQL.Append(" ,Firstname = @Firstname ");
strSQL.Append(" ,Lastname = @Lastname ");
strSQL.Append(" ,Email = @Email ");
strSQL.Append(" ,Telephone = @Telephone ");
strSQL.Append(" ,Mobile = @Mobile ");
strSQL.Append(" ,Address = @Address ");
strSQL.Append(" ,Province = @Province ");
strSQL.Append(" ,City = @City ");
strSQL.Append(" ,Zipcode = @Zipcode ");
strSQL.Append(" WHERE Username = @Username");
sqlcmd = new SqlCommand(strSQL.ToString(), Conn);
sqlcmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = this.txtPassword.Text;
sqlcmd.Parameters.Add("@Firstname", SqlDbType.VarChar).Value = this.txtFirstname.Text;
sqlcmd.Parameters.Add("@Lastname", SqlDbType.VarChar).Value = this.txtLastname.Text;
sqlcmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = this.txtEmail.Text;
sqlcmd.Parameters.Add("@Telephone", SqlDbType.VarChar).Value = this.txtTelephone.Text;
sqlcmd.Parameters.Add("@Mobile", SqlDbType.VarChar).Value = this.txtMobile.Text;
sqlcmd.Parameters.Add("@Address", SqlDbType.VarChar).Value = this.txtAddress.Text;
sqlcmd.Parameters.Add("@Province", SqlDbType.VarChar).Value = this.txtProvince.Text;
sqlcmd.Parameters.Add("@City", SqlDbType.VarChar).Value = this.txtCity.Text;
sqlcmd.Parameters.Add("@Zipcode", SqlDbType.VarChar).Value = this.txtZipcode.Text;
sqlcmd.Parameters.Add("@Username", SqlDbType.VarChar).Value = Session["strUsername"];
sqlcmd.ExecuteNonQuery();
Conn.Close();
Conn = null;
}
Tag : .NET, Web (ASP.NET), C#, VS 2010 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2012-09-10 20:30:08 |
By :
mashiplay |
View :
1005 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สงสัยจะต้องได้ใช้การ Debug ดูครับ
|
 |
 |
 |
 |
Date :
2012-09-11 06:09:00 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|