[มือใหม่ขอรบกวน]เออเร่อเกี่ยวกับการแก้ไขข้อมูล c#.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace testwork
{
public partial class updateprofile : System.Web.UI.Page
{
SqlConnection con = new SqlConnection();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Cus_id"] == null)
{
Response.Redirect("login.aspx");
}
if (!this.IsPostBack)
{
txt_id.Text = Session["Cus_id"].ToString();
txt_name.Text = Session["Cus_name"].ToString();
txt_address.Text = Session["Cus_add"].ToString();
txt_email.Text = Session["Cus_email"].ToString();
txt_tel.Text = Session["Cus_tel"].ToString();
txt_cardid.Text = Session["Cus_card"].ToString();
}
}
protected void btn_save_Click(object sender, EventArgs e)
{
string str = ConfigurationManager.ConnectionStrings["Dormcon"].ConnectionString;
con.ConnectionString = str;
con.Open();
SqlCommand cmd = new SqlCommand();
string sql = "Update Tb_CustomerOnline set Customer_ID ='" + txt_id.Text + "', Customer_NAME = '" + txt_name.Text + "', Customer_ADDRESS = '" + txt_address + "', Customer_EMAIL = '" + txt_email + "',Customer_TEL = '" + txt_tel + "',Customer_IDCARD = '" + txt_cardid.Text + "' where Customer_ID ='" + txt_id.Text + "'";
cmd.CommandText = sql;
cmd.Connection = con;
//cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
MsgBox("แก้ไขข้อมูลเรียบร้อยแล้ว");
}
private void MsgBox(string sMessage)
{
string msg = "<script language=\"javascript\">";
msg += "alert('" + sMessage + "');";
msg += "</script>";
Response.Write(msg);
}
}
}Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), C#, Windows
Date :
2018-01-08 23:13:27
By :
ัyoyo
View :
719
Reply :
1
Load balance : Server 03