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;public partial class CreateTopic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null)
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请先登录');location.href='TopicList.aspx?BoardID=" + Request.QueryString["BoardID"] + "'</script>"); // 提示需要登录并返回前一个页面
}
protected void btn_CreateTopic_Click(object sender, EventArgs e)
{
ForumTableAdapters.tbTopicTableAdapter topic = new ForumTableAdapters.tbTopicTableAdapter();
topic.Insert(Guid.NewGuid(), tb_TopicTitle.Text, tb_TopicContent.Text, new Guid(Request.QueryString["BoardID"]), new Guid(Request.QueryString["BoardID"]), new Guid(Session["UserID"].ToString()), DateTime.Now);
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('发表成功');location.href='TopicList.aspx?BoardID=" + Request.QueryString["BoardID"] + "'</script>");
}
}类
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;public partial class CreateTopic : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null)
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请先登录');location.href='TopicList.aspx?BoardID=" + Request.QueryString["BoardID"] + "'</script>"); // 提示需要登录并返回前一个页面
}
protected void btn_CreateTopic_Click(object sender, EventArgs e)
{
ForumTableAdapters.tbTopicTableAdapter topic = new ForumTableAdapters.tbTopicTableAdapter();
topic.Insert(Guid.NewGuid(), tb_TopicTitle.Text, tb_TopicContent.Text, new Guid(Request.QueryString["BoardID"]), new Guid(Request.QueryString["BoardID"]), new Guid(Session["UserID"].ToString()), DateTime.Now);
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('发表成功');location.href='TopicList.aspx?BoardID=" + Request.QueryString["BoardID"] + "'</script>");
}
}类
你复制粘贴的吧?
ForumTableAdapters这个是自定义的一个类,用来执行下面的insert。
光using没有用