大家进来帮帮小弟,很简单的问题.多谢!!
这段代码"clear.aspx"是用来清空数据库的,如何在点击该页上某一个清除按钮后,先出一个窗口提示是否确定清除,然后有确定或取消,如果点取消返回页面,如果点确定后,再跳出一个小窗口,显示该表已经清空,然后点确定关闭小窗口,,如何做?. 另外在该页面下添加一个返回按钮,返回上一页,比如上一页是"clearlogin.aspx".哪位大侠能直接把这三个功能添加到小弟代码中啊,谢谢!!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace CourseWork3
{
/// <summary>
/// </summary>
public class WebForm12 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.Button Button5;
protected System.Web.UI.WebControls.Label Label2;
protected System.Data.SqlClient.SqlConnection VisitConnection;
private void Page_Load(object sender, System.EventArgs e)
{
}
#region
override protected void OnInit(EventArgs e)
{
//
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// </summary>
private void InitializeComponent()
{
this.VisitConnection = new System.Data.SqlClient.SqlConnection();
this.Button5.Click += new System.EventHandler(this.Button5_Click);
this.Button4.Click += new System.EventHandler(this.Button4_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
//
// VisitConnection
//
this.VisitConnection.ConnectionString = "workstation id=erhtrc;packet size=4096;integrated security=SSPI;data source=erthr" +
"c;persist security info=False;initial catalog=VisitDays";
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
VisitConnection.Open();
SqlCommand cmd =
new SqlCommand("delete from Applicant",VisitConnection);
cmd.ExecuteReader();
}
finally{
VisitConnection.Close();
}
}
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
VisitConnection.Open();
SqlCommand cmd =
new SqlCommand("delete from Applications",VisitConnection);
cmd.ExecuteReader();
}
finally
{
VisitConnection.Close();
}
}
private void Button3_Click(object sender, System.EventArgs e)
{
try
{
VisitConnection.Open();
SqlCommand cmd =
new SqlCommand("delete from Attending",VisitConnection);
cmd.ExecuteReader();
}
finally
{
VisitConnection.Close();
}
}
private void Button4_Click(object sender, System.EventArgs e)
{
try
{
VisitConnection.Open();
SqlCommand cmd =
new SqlCommand("delete from Course",VisitConnection);
cmd.ExecuteReader();
}
finally
{
VisitConnection.Close();
}
}
private void Button5_Click(object sender, System.EventArgs e)
{
try
{
VisitConnection.Open();
SqlCommand cmd =
new SqlCommand("delete from OpenDay",VisitConnection);
cmd.ExecuteReader();
}
finally
{
VisitConnection.Close();
}
}
}
}
问题点数:0、回复次数:4Top
1 楼bylmy()回复于 2005-04-01 14:12:17 得分 0
谁来帮我Top
2 楼bylmy()回复于 2005-04-01 15:31:52 得分 0
upTop
3 楼lizq2004(Lee)回复于 2005-04-01 15:46:15 得分 0
if (MessageBox.Show("是否确定清除?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
{
//删除数据库
MessageBox.show("删除成功!");
}
else
{
//不删除
}
Top
4 楼bylmy()回复于 2005-04-01 22:44:05 得分 0
不行啊,小弟在VS.net里编译,有问题!Top




