交集INTERSECT:從兩個資料表取出同時存在的記錄。
聯集UNION:將兩個資料表的記錄都全部結合成在一起,如果有重複記錄,只顯示其中一筆。
差集EXCEPT:只取出A資料表中不包含與B資料表內相同的資料。
| 1 | SELECT column1, column2 FROM tableA |
| 2 | INTERSECT --or UNION or EXCEPT |
| 3 | SELECT column1, column2 FROM tableB |
| 1 | SELECT column1, column2 FROM tableA |
| 2 | INTERSECT --or UNION or EXCEPT |
| 3 | SELECT column1, column2 FROM tableB |
//指定來源網頁
WebClient url = new WebClient();
//將網頁來源資料暫存到記憶體內
MemoryStream ms = new MemoryStream(url.DownloadData("http://tw.stock.yahoo.com/q/q?s=1101"));
//以奇摩股市為例http://tw.stock.yahoo.com
//1101 表示為股票代碼
// 使用預設編碼讀入 HTML
HtmlDocument doc = new HtmlDocument();
doc.Load(ms, Encoding.Default);
// 裝載第一層查詢結果
HtmlDocument hdc = new HtmlDocument();
//XPath 來解讀它 /html[1]/body[1]/center[1]/table[2]/tr[1]/td[1]/table[1]
hdc.LoadHtml(doc.DocumentNode.SelectSingleNode("/html[1]/body[1]/center[1]/table[2]/tr[1]/td[1]/table[1]").InnerHtml);
// 取得個股標頭
HtmlNodeCollection htnode = hdc.DocumentNode.SelectNodes("./tr[1]/th");
// 取得個股數值
string[] txt = hdc.DocumentNode.SelectSingleNode("./tr[2]").InnerText.Trim().Split('\n');
int i = 0;
// 輸出資料
foreach (HtmlNode nodeHeader in htnode)
{
//將 "加到投資組合" 這個字串過濾掉
Response.Write(nodeHeader.InnerText + ":" + txt[i].Trim().Replace("加到投資組合", "") + "
");
i++;
}
//清除資料
doc = null;
hdc = null;
url = null;
ms.Close();
//指定來源網頁
WebClient url = new WebClient();
//將網頁來源資料暫存到記憶體內
MemoryStream ms = new MemoryStream(url.DownloadData("http://rate.bot.com.tw/Pages/Static/UIP003.zh-TW.htm"));
//以台灣銀行為範例
// 使用預設編碼讀入 HTML
HtmlDocument doc = new HtmlDocument();
doc.Load(ms, Encoding.Default);
//取得現在的日期
Response.Write("現在時間:" + DateTime.Now + "
");
// 在Html內表示換行
// 取得匯率
for(int x=3;x<=21;x++)
{
string txt1 = doc.DocumentNode.SelectSingleNode(@"/html[1]/body[1]/ul[1]/li[2]/center[1]/div[1]/div[2]/table[2]/tr[" + x + "]/td[1]").InnerText;
string txt2 = doc.DocumentNode.SelectSingleNode(@"/html[1]/body[1]/ul[1]/li[2]/center[1]/div[1]/div[2]/table[2]/tr[" + x + "]/td[2]").InnerText;
string txt3 = doc.DocumentNode.SelectSingleNode(@"/html[1]/body[1]/ul[1]/li[2]/center[1]/div[1]/div[2]/table[2]/tr[" + x + "]/td[3]").InnerText;
string txt4 = doc.DocumentNode.SelectSingleNode(@"/html[1]/body[1]/ul[1]/li[2]/center[1]/div[1]/div[2]/table[2]/tr[" + x + "]/td[4]").InnerText;
string txt5 = doc.DocumentNode.SelectSingleNode(@"/html[1]/body[1]/ul[1]/li[2]/center[1]/div[1]/div[2]/table[2]/tr[" + x + "]/td[5]").InnerText;
string totle = string.Format("幣別:{0} ,買入現金匯率:{1} ,賣出即期匯率:{2} ,買入遠期匯率:{3} ,賣出歷史匯率:{4}", txt1, txt2, txt3, txt4, txt5);
Response.Write(totle + "
");
}
//清除資料
doc = null;
url = null;
ms.Close();
|
Protect Sub FormView1_DataBound(ByVal sender as Object, ByVal e As system.EventArgs) Handles FormView1.DataBound
CType(FormView1.FindControl(”時間欄位”),TextBox).Text=Now
CType(FormView1.FindControl(”IP欄位”),TextBox).Text=Request.ServerVariables(”REMOTE_ADDR”)End Sub另外一種方式,是在Inserting時,再把值代入,這種方法,畫面中不需要用TextBox來顯示。Protected Sub FormView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting
e.Values.Item(”時間欄位”) = Now
e.Values.Item(”IP欄位”) = Request.ServerVariables(”REMOTE_ADDR”) End Sub$(".editable").editable(function(value, settings) {var myParam = new Object(); // 要傳給 Server 用的欄位 myParam.key = this.id.replace( /key/i, "" ); myParam.param = value; // 回呼函式使用的欄位 myParam.revert = this.revert; // 元素原始內容 myParam.rtnValue = value; // 使用者修改過之內容 $.getJSON( "json/updateData", // Server 上更新資料之位址 myParam, // 傳入之參數 function( json ) { // 回呼函式/callback function if( !json.status ) { // 假如更新失敗就傳回原始內容 myParam.rtnValue = myParam.revert; } } ); return( myParam.rtnValue ); // 傳回動作結束後要顯示的內容 }, { loadurl : "json/loadPMData", type : "select",
indicator : "< img src='images/indicator.gif' >",submit : "OK", tooltip: "滑鼠雙擊此欄位後即可編輯", event : "dblclick" } );
| 1 | if (Session["account"]==null) |
| 2 | { |
| 3 | return; |
| 4 | } |