| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 436 人关注过本帖
标题:[求助]SqlCommandBuilder在如下代码中的作用??
取消只看楼主 加入收藏
C_B_Lu
Rank: 1
等 级:新手上路
威 望:1
帖 子:453
专家分:0
注 册:2006-1-10
收藏
 问题点数:0 回复次数:0 
[求助]SqlCommandBuilder在如下代码中的作用??
下面这两段代码中,红色部份的代码是什么意思????起什么作用?

1.下面这段代码中,红色部份的代码是什么意思????

SqlConnection thisConn = new SqlConnection(strSqlConnection);
thisConn.Open();
SqlDataAdapter this.Adapter = new SqlDataAdapter("SELECT CustomerID,CompanyName FROM Customers" thisConn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter);

DataSet thisDataSet = new DataSet();

SqDataAdapter custAdapter = new SqlDataAdapter("SELECT * FROM Customers",thisConn);
SqDataAdapter orderAdapter = new SqlDataAdapter("SELECT * FROM Orders",thisConn);
custAdapter.Fill(thisDataSet,"Customers");
orderAdapter.Fill(thisDataSet,"Orders");
DataRelation custOrderRel = this.DataSet.Retations.Add("CustOrders",thisDataSet.Tables["Customers"].Columns["CustomerID"],
thisDataSet.Table["Orders"].Columns["CustomerID"]);
foreach(DataRow custRow in thisDataSet.Tables["Customers"].Rows)
{
Console.WriteLine("Customer ID:" + custRow["CustomerID"] + " Name:" + custRow["CompanyName"]);
foreach(DataRow orderRow in custRow.GetChildRows(CustOrderRel))
{
Console.WriteLine(" Order ID:" + orderRow["OrderID"]);
}
}
thisConn.Close();


2.下面这段代码中,红色部份的代码是什么意思????

SqlConnection thisConn = new SqlConnection(strSqlConnection);
thisConn.Open();
SqlDataAdapter this.Adapter = new SqlDataAdapter("SELECT CustomerID,CompanyName FROM Customers" thisConn);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter);

DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet,"Customers");
Console.WriteLine("name before change:{0}",thisDataSet.Table["Customers"].Rows[9]["CompanyName"]);
thisDataSet.Tables["Customers"].Rows[9]["CompanyName"] = "Acme,Inc";
thisAdapter.Update(this.DataSet,"Customers");
Console.WriteLine("name after change:{0}",thisDataSet.Table["Customers"].Rows[9]["CompanyName"]);
thisConn.Close();


搜索更多相关主题的帖子: 代码 
2007-05-21 12:55
快速回复:[求助]SqlCommandBuilder在如下代码中的作用??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023177 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved