📄 modsingle.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class ModSingle : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//从文件Web.config中读取连接字符串
string strconn = ConfigurationSettings.AppSettings["dsn"];
//连接本地计算机的LMS数据库
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
string mysql = "update dzxx set birthday='" + this.TextBox1.Text + "',duzhesex='" + this.TextBox2.Text + "',banzhengdate='" + this.TextBox3.Text + "',zhengjiannumber='" + this.TextBox4.Text + "',tel='" + this.TextBox5.Text + "',Email='" + this.TextBox6.Text+ "'";
//创建Command对象
SqlCommand cm = new SqlCommand(mysql, cn);
//利用Command对象调用存储过程
//SqlCommand cm = new SqlCommand(mysql, cn);
//将命令类型转为存储类型
//cm.CommandType = CommandType.StoredProcedure;
////添加参数
//cm.Parameters.Add("@birthday", SqlDbType.VarChar);
//cm.Parameters.Add("@duzhesex", SqlDbType.VarChar);
//cm.Parameters.Add("@banzhengdate", SqlDbType.VarChar);
//cm.Parameters.Add("@zhengjiannumber", SqlDbType.VarChar);
//cm.Parameters.Add("@tel", SqlDbType.VarChar);
//cm.Parameters.Add("@Email", SqlDbType.VarChar);
////给存储过程的参数付值
//cm.Parameters["@birthday"].Value = this.TextBox1.Text.ToString();
//cm.Parameters["@duzhesex"].Value = this.TextBox2.Text.ToString();
//cm.Parameters["@banzhengdate"].Value = this.TextBox3.Text.ToString();
//cm.Parameters["@zhengjiannumber"].Value = this.TextBox4.Text.ToString();
//cm.Parameters["@tel"].Value = this.TextBox5.Text.ToString();
//cm.Parameters["@Email"].Value = this.TextBox6.Text.ToString();
cm.ExecuteNonQuery();
//关闭连接
this.Label8.Text = "修改成功!请";
cn.Close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -