当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 昨天折腾了一晚上,哪位高手帮我看看!急!

ASP.NET
ASP.NET错误处理:Runtime Error
如何使用ADO.NET Entity Framework从数据库中获取图片
ASP.NET教程:WaitHandle类
ASP.Net中Ado.Net Entity Framework实际项目应用释疑
ASP.NET页面中控制部分元素隐现的方法
asp.net网站开发中使用Sqlite嵌入式数据库
ASP.NET教程:调用WebService的源码
.NET中的垃圾回收
asp.net教程:编译错误同时存在于不同dll中
ASP.NET4.0新改进和新特性
ASP教程:防SQL注入
ASP.NET教程:HttpContext类Current属性
在Win2003 IIS 6.0中安装ASP.net环境
asp.net2.0中App_GlobalResources用途
利用Windows系统服务自动更新网站
无缝的缓存读取:双存储缓存策略
WebServices的性能特别慢是真的吗?
ASP.NET MVC的Web应用程序更直观
PHP和ASP.NET代码哪个运行速度更快?
ASP.NET常用代码

ASP.NET 中的 昨天折腾了一晚上,哪位高手帮我看看!急!


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 116 ::
收藏到网摘: n/a


想用DataAdapter 把DataSet中的数据更新到数据库 可是死活也更新新不进去,只在DataSet中更新了,数据库里一点也没变 不知道为什么,以下是代码,望高手指点,感激不尽。
string sql = "SELECT Title, Author, Type, Content, PDate FROM Article;"; SqlConnection conn = new SqlConnection(); conn.ConnectionString ="Data Source = (local); database = Finance; Integrated Security = SSPI;"; SqlCommand myCom = conn.CreateCommand(); myCom.CommandText = sql; SqlDataAdapter myAda = new SqlDataAdapter(myCom); myAda.InsertCommand = myCom; DataSet ds = new DataSet(); conn.Open(); myAda.Fill(ds,"test"); DataRow newRow = ds.Tables["test"].NewRow(); newRow["Title"] = "title2"; newRow["Author"] = "mstc"; newRow["Type"] = "type2"; newRow["Content"] = "Content2"; newRow["PDate"] = "Today"; ds.Tables["test"].Rows.Add(newRow); try { myAda.Update(ds,"test"); } catch(Exception ex) { this.Response.Write(ex.Message); } this.DataGrid1.DataSource = ds.Tables["test"].DefaultView; this.DataGrid1.DataBind();

以上代码数据库连接绝对没有问题,运行中也没有抛出异常,DataSet中的增加了新行,可是教用UpDate
方法后 ,数据库里并没有改变,不知道为什么