//aspx ページの LinkButton 定義
<asp:LinkButton ID="linkUpdate" runat="server" OnClick="linkUpdate_Click">Update </asp:LinkButton>
//linkUpdate_Click - リンクボタンがクリックされたときに実行したいアクション
protected void linkUpdate_Click(object sender, EventArgs e)
{
string DeptName = txtName.Text;
string Profile = txtProfile.Text;
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
string sql = "update Sectors set DeptName = '" + txtName.Text + "',Profile='" + txtProfile.Text + "' where DeptID =1";
connection.Open();
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.ExecuteNonQuery();
Response.Redirect("Architecture.aspx");
connection.Close();
}
}