|
|
|
Web (ASP.NET), C# -> Update ไม่ได้แค่ค่าเดียว งงมากไม่ทราบสาเหตุ ช่วยทีครับผม |
|
|
|
|
|
|
|
อัพเดทได้แค่รูปส่วน textbox อัพเดทไม่ได้เลย งงมากครับ
Code (C#)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Web.Mail;
namespace WebApplication1
{
public partial class WebForm5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ReEmeetingConnectionString"].ConnectionString);
con.Open();
//string cmdStr = "SELECT * FROM members WHERE username ='" + Session["id"] +"'";
string cmdStr = "SELECT * FROM members WHERE member_id ='" + Session["id"] + "'";
SqlCommand cmdd = new SqlCommand(cmdStr, con);
SqlDataReader objReader = cmdd.ExecuteReader();
while (objReader.Read())
{
txtName.Text = objReader.GetString(1);
txtLastName.Text = objReader.GetString(2);
txtinstitution.Text = objReader.GetString(3);
txtPosition.Text = objReader.GetString(4);
txtTel.Text = objReader.GetString(5);
txtEmail.Text = objReader.GetString(6);
}
objReader.Close();
con.Close();
}
protected void btnRegister_Click(object sender, EventArgs e)
{
SqlCommand objCmd = new SqlCommand();
String strSQL;
SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ReEmeetingConnectionString"].ConnectionString);
objConn.Open();
if (this.FileUpload1.HasFile)
{
this.FileUpload1.SaveAs(Server.MapPath("Myfiles/" + FileUpload1.FileName));
//this.lblText.Text = "<b>" + FileUpload1.FileName + "</b> Uploaded.<br>";
strSQL = "UPDATE members SET " +
" firstname = '" + txtName.Text + "' " +
" ,lastname = '" + txtLastName.Text + "' " +
" ,institution = '" + txtinstitution.Text + "' " +
" ,position = '" + txtPosition.Text + "' " +
" ,telephone = '" + txtTel.Text + "' " +
" ,email = '" + txtEmail.Text + "' " +
" ,picture = '" + FileUpload1.FileName + "' " +
" WHERE member_id ='" + Session["id"] + "'";
objCmd.Connection = objConn;
objCmd.CommandText = strSQL;
objCmd.CommandType = CommandType.Text;
objCmd.ExecuteNonQuery();
objConn.Close();
}
else
{
strSQL = "UPDATE members SET " +
" firstname = '" + this.txtName.Text + "' " +
" ,lastname = '" + this.txtLastName.Text + "' " +
" ,institution = '" + this.txtinstitution.Text + "' " +
" ,position = '" + this.txtPosition.Text + "' " +
" ,telephone = '" + this.txtTel.Text + "' " +
" ,email = '" + this.txtEmail.Text + "' " +
" ,picture = '" + "null" + "' " +
" WHERE member_id ='" + Session["id"] + "'";
objCmd.Connection = objConn;
objCmd.CommandText = strSQL;
objCmd.CommandType = CommandType.Text;
objCmd.ExecuteNonQuery();
objConn.Close();
}
}
}
}
Tag : ASP.NET Web (ASP.NET), C#
|
|
|
|
|
|
Date :
2012-08-24 03:57:00 |
By :
thunzzz |
View :
957 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา Error มาดูครับ หรือไม่ก็ Debug ดูค่า SQL หน่อยครับ
|
|
|
|
|
Date :
2012-08-24 09:07:39 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|