asp.net无法更新数据库!
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business;
using Entity;
public partial class EgNewsEdit : System.Web.UI.Page
{
NewsBusiness nb = new NewsBusiness();
NewsEntity ne = new NewsEntity();
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = Convert.ToString(Session["newsid"]);
DataSet ds = nb.GetNewsInfoByID(Label2.Text);
TextBox1.Text = ds.Tables[0].Rows[0][1].ToString();
TextBox2.Text = ds.Tables[0].Rows[0][2].ToString();
TextBox3.Text = ds.Tables[0].Rows[0][3].ToString();
TextBox4.Text = ds.Tables[0].Rows[0][4].ToString();
FreeTextBox1.Text = ds.Tables[0].Rows[0][5].ToString();
Label1.Text = ds.Tables[0].Rows[0][6].ToString();
DropDownList1.Text = ds.Tables[0].Rows[0][7].ToString();
DropDownList2.Text = ds.Tables[0].Rows[0][8].ToString();
ImageButton1.ImageUrl = ds.Tables[0].Rows[0][9].ToString();
DropDownList3.Text = ds.Tables[0].Rows[0][10].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
ne.ID = Convert.ToInt32(Label2.Text);
ne.Name = TextBox1.Text;
ne.Writer = TextBox2.Text;
ne.Source = TextBox3.Text;
ne.Editor = TextBox4.Text;
ne.Content = FreeTextBox1.Text;
ne.Time = Label1.Text;
ne.Range = DropDownList1.Text;
ne.Classify = DropDownList2.Text;
ne.Image = ImageButton1.ImageUrl;
ne.Hot = DropDownList3.Text;
int count = nb.UpdateNews(ne);
if (count >= 0)
{
Response.Redirect("EgNewsList.aspx");
}
}
}
就是先从其他网页获取数据,点击Button1再更新到数据库,但Button1_Click无法将数据更新到数据库,求高手指点啊!谢谢了~
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business;
using Entity;
public partial class EgNewsEdit : System.Web.UI.Page
{
NewsBusiness nb = new NewsBusiness();
NewsEntity ne = new NewsEntity();
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = Convert.ToString(Session["newsid"]);
DataSet ds = nb.GetNewsInfoByID(Label2.Text);
TextBox1.Text = ds.Tables[0].Rows[0][1].ToString();
TextBox2.Text = ds.Tables[0].Rows[0][2].ToString();
TextBox3.Text = ds.Tables[0].Rows[0][3].ToString();
TextBox4.Text = ds.Tables[0].Rows[0][4].ToString();
FreeTextBox1.Text = ds.Tables[0].Rows[0][5].ToString();
Label1.Text = ds.Tables[0].Rows[0][6].ToString();
DropDownList1.Text = ds.Tables[0].Rows[0][7].ToString();
DropDownList2.Text = ds.Tables[0].Rows[0][8].ToString();
ImageButton1.ImageUrl = ds.Tables[0].Rows[0][9].ToString();
DropDownList3.Text = ds.Tables[0].Rows[0][10].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
ne.ID = Convert.ToInt32(Label2.Text);
ne.Name = TextBox1.Text;
ne.Writer = TextBox2.Text;
ne.Source = TextBox3.Text;
ne.Editor = TextBox4.Text;
ne.Content = FreeTextBox1.Text;
ne.Time = Label1.Text;
ne.Range = DropDownList1.Text;
ne.Classify = DropDownList2.Text;
ne.Image = ImageButton1.ImageUrl;
ne.Hot = DropDownList3.Text;
int count = nb.UpdateNews(ne);
if (count >= 0)
{
Response.Redirect("EgNewsList.aspx");
}
}
}
就是先从其他网页获取数据,点击Button1再更新到数据库,但Button1_Click无法将数据更新到数据库,求高手指点啊!谢谢了~
...全文
相关推荐
asp.net英语听说 教学系统 教学平台
该项目是一个基于ASP.NET的英语听说教学系统,旨在实现在线语言教学功能。代码核心包含多个数据库操作类,如Class1、DB和Database,用于处理与SQL Server的数据交互。同时提供了工
基于C#+Asp.net版的SqlManagement在线数据管理系统源码
综上所述,这个基于C#和Asp.net的SqlManagement在线数据管理系统源码提供了全面的数据库管理功能,包括登录验证、数据库和表的创建、查看表详情等。
ASP.NET C#在线音乐网站带数据库2017更新
ASP.NET C#在线音乐网站是一个基于.NET框架的Web应用程序,主要使用C#编程语言进行开发。这个项目在2017年进行了更新,提供了一套完整的解决方案,适用于毕业设计或初学者的学习实践。
浅谈ASP(ASP.NET)中数据库连接方法
本文介绍了ASP和ASP.NET中常用的数据库连接方法,包括DSN连接、非DSN连接及Access OLE DB连接方式。同时提供了示例代码说明具体实现,并对ADO和ADO.NET在数据库访问中的差异
asp读取db3数据库
ODBC Driver};Database=path_to_your_db3_file;"```请将"path_to_your_db3_file"替换为实际的DB3数据库文件路径。


