此篇主要是在參考 linq order by 的寫法 參考
--
結果光看到 C# 的 class 這麼簡易 , 還真是有點心情差
因近期在研究找 Json.net 能否讓我的開發更順更多運用,差不多都是朝 class 部分
以前很少用 class 來當資料餵養 , VBNET 寫 class 還是跟 vb6 一樣無法省工.
底下實作了 list of class (嘿, 我也學上面參考的;將code jpg , 他那個應該是套用外掛 code to png)
--
2011年10月31日 星期一
Json.net 序列化和反序列化
引用來源
參考2(反序列化)
--
參考2 ,重點在:
JObject o = JObject.Parse(json); // This would be the string you defined above
// The next line should yield a List<> of Person objects...
List list = JsonConvert.DeserializeObject
---
導讀:JSON是專門為瀏覽器中的網頁上運行的JavaScript代碼而設計的一種數據格式。在網站應用中使用JSON的場景越來越多,本文介紹 ASP.NET中JSON的序列化和反序列化,主要對JSON的簡單介紹,ASP.NET如何序列化和反序列化的處理,在序列化和反序列化對日期時間、集合、字典的處理。
一、JSON簡介
JSON(JavaScript Object Notation,JavaScript對像表示法)是一種輕量級的數據交換格式。
JSON是「名值對」的集合。結構由大括號'{}',中括號'[]',逗號',',冒號':',雙引號'「」'組成,包含的數據類型有Object,Number,Boolean,String,Array, NULL等。
JSON具有以下的形式:
對像(Object)是一個無序的「名值對」集合,一個對像以」{」開始,」}」結束。每個「名」後跟著一個」:」,多個「名值對」由逗號分隔。如:
var user={"name":"張三","gender":"男","birthday":"1980-8-8"}
數組(Array)是值的有序集合,一個數組以「[」開始,以「]」結束,值之間使用「,」分隔。如:
var userlist=[{"user":{"name":"張三","gender":"男","birthday":"1980-8-8"}},{"user":{"name":"李四","gender":"男","birthday":"1985-5-8"}}];
字符串(String)是由雙引號包圍的任意數量的Unicode字符的集合,使用反斜線轉義。
二、對JSON數據進行序列化和反序列化
可以使用DataContractJsonSerializer類將類型實例序列化為JSON字符串,並將JSON字符串反序列化為類型實例。 DataContractJsonSerializer在System.Runtime.Serialization.Json命名空間下,.NET Framework 3.5包含在System.ServiceModel.Web.dll中,需要添加對其的引用;.NET Framework 4在System.Runtime.Serialization中。
利用DataContractJsonSerializer序列化和反序列化的代碼:
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Web;
5: using System.Runtime.Serialization.Json;
6: using System.IO;
7: using System.Text;
8:
9: ///
10: /// JSON序列化和反序列化輔助類
11: ///
12: public class JsonHelper
13: {
14: ///
15: /// JSON序列化
16: ///
17: public static string JsonSerializer(T t)
18: {
19: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
20: MemoryStream ms = new MemoryStream();
21: ser.WriteObject(ms, t);
22: string jsonString = Encoding.UTF8.GetString(ms.ToArray());
23: ms.Close();
24: return jsonString;
25: }
26:
27: ///
28: /// JSON反序列化
29: ///
30: public static T JsonDeserialize(string jsonString)
31: {
32: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
33: MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
34: T obj = (T)ser.ReadObject(ms);
35: return obj;
36: }
37: }
序列化Demo:
簡單對像Person:
1: public class Person
2: {
3: public string Name { get; set; }
4: public int Age { get; set; }
5: }
序列化為JSON字符串:
1: protected void Page_Load(object sender, EventArgs e)
2: {
3: Person p = new Person();
4: p.Name = "張三";
5: p.Age = 28;
6:
7: string jsonString = JsonHelper.JsonSerializer(p);
8: Response.Write(jsonString);
9: }
輸出結果:
{"Age":28,"Name":"張三"}
反序列化Demo:
1: protected void Page_Load(object sender, EventArgs e)
2: {
3: string jsonString = "{\"Age\":28,\"Name\":\"張三\"}";
4: Person p = JsonHelper.JsonDeserialize(jsonString);
5: }
運行結果:
ASP.NET中的JSON序列化和反序列化還可以使用JavaScriptSerializer,在 System.Web.Script.Serializatioin命名空間下,需引用System.Web.Extensions.dll.也可以使用 JSON.NET.
三、JSON序列化和反序列化日期時間的處理
JSON格式不直接支持日期和時間。DateTime值值顯示為「/Date(700000+0500)/」形式的JSON字符串,其中第一個數字(在提 供的示例中為 700000)是 GMT 時區中自 1970 年 1 月 1 日午夜以來按正常時間(非夏令時)經過的毫秒數。該數字可以是負數,以表示之前的時間。示例中包括「+0500」的部分可選,它指示該時間屬於Local 類型,即它在反序列化時應轉換為本地時區。如果沒有該部分,則會將時間反序列化為Utc。
修改Person類,添加LastLoginTime:
1: public class Person
2: {
3: public string Name { get; set; }
4: public int Age { get; set; }
5: public DateTime LastLoginTime { get; set; }
6: }
1: Person p = new Person();
2: p.Name = "張三";
3: p.Age = 28;
4: p.LastLoginTime = DateTime.Now;
5:
6: string jsonString = JsonHelper.JsonSerializer(p);
序列化結果:
{"Age":28,"LastLoginTime":"\/Date(1294499956278+0800)\/","Name":"張三"}
1. 在後台使用正則表達式對其替換處理。修改JsonHelper:
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Web;
5: using System.Runtime.Serialization.Json;
6: using System.IO;
7: using System.Text;
8: using System.Text.RegularExpressions;
9:
10: ///
11: /// JSON序列化和反序列化輔助類
12: ///
13: public class JsonHelper
14: {
15: ///
16: /// JSON序列化
17: ///
18: public static string JsonSerializer(T t)
19: {
20: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
21: MemoryStream ms = new MemoryStream();
22: ser.WriteObject(ms, t);
23: string jsonString = Encoding.UTF8.GetString(ms.ToArray());
24: ms.Close();
25: //替換Json的Date字符串
26: string p = @"\\/Date\((\d+)\+\d+\)\\/";
27: MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
28: Regex reg = new Regex(p);
29: jsonString = reg.Replace(jsonString, matchEvaluator);
30: return jsonString;
31: }
32:
33: ///
34: /// JSON反序列化
35: ///
36: public static T JsonDeserialize(string jsonString)
37: {
38: //將"yyyy-MM-dd HH:mm:ss"格式的字符串轉為"\/Date(1294499956278+0800)\/"格式
39: string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
40: MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
41: Regex reg = new Regex(p);
42: jsonString = reg.Replace(jsonString, matchEvaluator);
43: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
44: MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
45: T obj = (T)ser.ReadObject(ms);
46: return obj;
47: }
48:
49: ///
50: /// 將Json序列化的時間由/Date(1294499956278+0800)轉為字符串
51: ///
52: private static string ConvertJsonDateToDateString(Match m)
53: {
54: string result = string.Empty;
55: DateTime dt = new DateTime(1970,1,1);
56: dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value));
57: dt = dt.ToLocalTime();
58: result = dt.ToString("yyyy-MM-dd HH:mm:ss");
59: return result;
60: }
61:
62: ///
63: /// 將時間字符串轉為Json時間
64: ///
65: private static string ConvertDateStringToJsonDate(Match m)
66: {
67: string result = string.Empty;
68: DateTime dt = DateTime.Parse(m.Groups[0].Value);
69: dt = dt.ToUniversalTime();
70: TimeSpan ts = dt - DateTime.Parse("1970-01-01");
71: result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
72: return result;
73: }
74: }
序列化Demo:
1: Person p = new Person();
2: p.Name = "張三";
3: p.Age = 28;
4: p.LastLoginTime = DateTime.Now;
5:
6: string jsonString = JsonHelper.JsonSerializer(p);
運行結果:
{"Age":28,"LastLoginTime":"2011-01-09 01:00:56","Name":"張三"}
反序列化Demo:
string json = "{\"Age\":28,\"LastLoginTime\":\"2011-01-09 00:30:00\",\"Name\":\"張三\"}";
p=JsonHelper.JsonDeserialize(json);
運行結果:
在後台替換字符串適用範圍比較窄,如果考慮到全球化的有多種語言還會更麻煩。
2. 利用JavaScript處理
1: function ChangeDateFormat(jsondate) {
2: jsondate = jsondate.replace("/Date(", "").replace(")/", "");
3: if (jsondate.indexOf("+") > 0) {
4: jsondate = jsondate.substring(0, jsondate.indexOf("+"));
5: }
6: else if (jsondate.indexOf("-") > 0) {
7: jsondate = jsondate.substring(0, jsondate.indexOf("-"));
8: }
9:
10: var date = new Date(parseInt(jsondate, 10));
11: var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
12: var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
13: return date.getFullYear() + "-" + month + "-" + currentDate;
14: }
簡單Demo :
ChangeDateFormat("\/Date(1294499956278+0800)\/");
結果:
四、JSON序列化和反序列化集合、字典、數組的處理
在JSON數據中,所有的集合、字典和數組都表示為數組。
List序列化:
1: List list = new List()
2: {
3: new Person(){ Name="張三", Age=28},
4: new Person(){ Name="李四", Age=25}
5: };
6:
7: string jsonString = JsonHelper.JsonSerializer
序列化結果:
"[{\"Age\":28,\"Name\":\"張三\"},{\"Age\":25,\"Name\":\"李四\"}]"
字典不能直接用於JSON,Dictionary字典轉化為JSON並不是跟原來的字典格式一致,而是形式以Dictionary的Key作為名稱」Key「的值,以Dictionary的Value作為名稱為」Value「的值 。如:
1: Dictionary dic = new Dictionary();
2: dic.Add("Name", "張三");
3: dic.Add("Age", "28");
4:
5: string jsonString = JsonHelper.JsonSerializer < Dictionary>(dic);
序列化結果:
1: "[{\"Key\":\"Name\",\"Value\":\"張三\"},{\"Key\":\"Age\",\"Value\":\"28\"}]"
參考2(反序列化)
--
參考2 ,重點在:
JObject o = JObject.Parse(json); // This would be the string you defined above
// The next line should yield a List<> of Person objects...
List
- >(o["data"].ToString());
---
導讀:JSON是專門為瀏覽器中的網頁上運行的JavaScript代碼而設計的一種數據格式。在網站應用中使用JSON的場景越來越多,本文介紹 ASP.NET中JSON的序列化和反序列化,主要對JSON的簡單介紹,ASP.NET如何序列化和反序列化的處理,在序列化和反序列化對日期時間、集合、字典的處理。
一、JSON簡介
JSON(JavaScript Object Notation,JavaScript對像表示法)是一種輕量級的數據交換格式。
JSON是「名值對」的集合。結構由大括號'{}',中括號'[]',逗號',',冒號':',雙引號'「」'組成,包含的數據類型有Object,Number,Boolean,String,Array, NULL等。
JSON具有以下的形式:
對像(Object)是一個無序的「名值對」集合,一個對像以」{」開始,」}」結束。每個「名」後跟著一個」:」,多個「名值對」由逗號分隔。如:
var user={"name":"張三","gender":"男","birthday":"1980-8-8"}
數組(Array)是值的有序集合,一個數組以「[」開始,以「]」結束,值之間使用「,」分隔。如:
var userlist=[{"user":{"name":"張三","gender":"男","birthday":"1980-8-8"}},{"user":{"name":"李四","gender":"男","birthday":"1985-5-8"}}];
字符串(String)是由雙引號包圍的任意數量的Unicode字符的集合,使用反斜線轉義。
二、對JSON數據進行序列化和反序列化
可以使用DataContractJsonSerializer類將類型實例序列化為JSON字符串,並將JSON字符串反序列化為類型實例。 DataContractJsonSerializer在System.Runtime.Serialization.Json命名空間下,.NET Framework 3.5包含在System.ServiceModel.Web.dll中,需要添加對其的引用;.NET Framework 4在System.Runtime.Serialization中。
利用DataContractJsonSerializer序列化和反序列化的代碼:
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Web;
5: using System.Runtime.Serialization.Json;
6: using System.IO;
7: using System.Text;
8:
9: ///
10: /// JSON序列化和反序列化輔助類
11: ///
12: public class JsonHelper
13: {
14: ///
15: /// JSON序列化
16: ///
17: public static string JsonSerializer
18: {
19: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
20: MemoryStream ms = new MemoryStream();
21: ser.WriteObject(ms, t);
22: string jsonString = Encoding.UTF8.GetString(ms.ToArray());
23: ms.Close();
24: return jsonString;
25: }
26:
27: ///
28: /// JSON反序列化
29: ///
30: public static T JsonDeserialize
31: {
32: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
33: MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
34: T obj = (T)ser.ReadObject(ms);
35: return obj;
36: }
37: }
序列化Demo:
簡單對像Person:
1: public class Person
2: {
3: public string Name { get; set; }
4: public int Age { get; set; }
5: }
序列化為JSON字符串:
1: protected void Page_Load(object sender, EventArgs e)
2: {
3: Person p = new Person();
4: p.Name = "張三";
5: p.Age = 28;
6:
7: string jsonString = JsonHelper.JsonSerializer
8: Response.Write(jsonString);
9: }
輸出結果:
{"Age":28,"Name":"張三"}
反序列化Demo:
1: protected void Page_Load(object sender, EventArgs e)
2: {
3: string jsonString = "{\"Age\":28,\"Name\":\"張三\"}";
4: Person p = JsonHelper.JsonDeserialize
5: }
運行結果:
ASP.NET中的JSON序列化和反序列化還可以使用JavaScriptSerializer,在 System.Web.Script.Serializatioin命名空間下,需引用System.Web.Extensions.dll.也可以使用 JSON.NET.
三、JSON序列化和反序列化日期時間的處理
JSON格式不直接支持日期和時間。DateTime值值顯示為「/Date(700000+0500)/」形式的JSON字符串,其中第一個數字(在提 供的示例中為 700000)是 GMT 時區中自 1970 年 1 月 1 日午夜以來按正常時間(非夏令時)經過的毫秒數。該數字可以是負數,以表示之前的時間。示例中包括「+0500」的部分可選,它指示該時間屬於Local 類型,即它在反序列化時應轉換為本地時區。如果沒有該部分,則會將時間反序列化為Utc。
修改Person類,添加LastLoginTime:
1: public class Person
2: {
3: public string Name { get; set; }
4: public int Age { get; set; }
5: public DateTime LastLoginTime { get; set; }
6: }
1: Person p = new Person();
2: p.Name = "張三";
3: p.Age = 28;
4: p.LastLoginTime = DateTime.Now;
5:
6: string jsonString = JsonHelper.JsonSerializer
序列化結果:
{"Age":28,"LastLoginTime":"\/Date(1294499956278+0800)\/","Name":"張三"}
1. 在後台使用正則表達式對其替換處理。修改JsonHelper:
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Web;
5: using System.Runtime.Serialization.Json;
6: using System.IO;
7: using System.Text;
8: using System.Text.RegularExpressions;
9:
10: ///
11: /// JSON序列化和反序列化輔助類
12: ///
13: public class JsonHelper
14: {
15: ///
16: /// JSON序列化
17: ///
18: public static string JsonSerializer
19: {
20: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
21: MemoryStream ms = new MemoryStream();
22: ser.WriteObject(ms, t);
23: string jsonString = Encoding.UTF8.GetString(ms.ToArray());
24: ms.Close();
25: //替換Json的Date字符串
26: string p = @"\\/Date\((\d+)\+\d+\)\\/";
27: MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
28: Regex reg = new Regex(p);
29: jsonString = reg.Replace(jsonString, matchEvaluator);
30: return jsonString;
31: }
32:
33: ///
34: /// JSON反序列化
35: ///
36: public static T JsonDeserialize
37: {
38: //將"yyyy-MM-dd HH:mm:ss"格式的字符串轉為"\/Date(1294499956278+0800)\/"格式
39: string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
40: MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
41: Regex reg = new Regex(p);
42: jsonString = reg.Replace(jsonString, matchEvaluator);
43: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
44: MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
45: T obj = (T)ser.ReadObject(ms);
46: return obj;
47: }
48:
49: ///
50: /// 將Json序列化的時間由/Date(1294499956278+0800)轉為字符串
51: ///
52: private static string ConvertJsonDateToDateString(Match m)
53: {
54: string result = string.Empty;
55: DateTime dt = new DateTime(1970,1,1);
56: dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value));
57: dt = dt.ToLocalTime();
58: result = dt.ToString("yyyy-MM-dd HH:mm:ss");
59: return result;
60: }
61:
62: ///
63: /// 將時間字符串轉為Json時間
64: ///
65: private static string ConvertDateStringToJsonDate(Match m)
66: {
67: string result = string.Empty;
68: DateTime dt = DateTime.Parse(m.Groups[0].Value);
69: dt = dt.ToUniversalTime();
70: TimeSpan ts = dt - DateTime.Parse("1970-01-01");
71: result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
72: return result;
73: }
74: }
序列化Demo:
1: Person p = new Person();
2: p.Name = "張三";
3: p.Age = 28;
4: p.LastLoginTime = DateTime.Now;
5:
6: string jsonString = JsonHelper.JsonSerializer
運行結果:
{"Age":28,"LastLoginTime":"2011-01-09 01:00:56","Name":"張三"}
反序列化Demo:
string json = "{\"Age\":28,\"LastLoginTime\":\"2011-01-09 00:30:00\",\"Name\":\"張三\"}";
p=JsonHelper.JsonDeserialize
運行結果:
在後台替換字符串適用範圍比較窄,如果考慮到全球化的有多種語言還會更麻煩。
2. 利用JavaScript處理
1: function ChangeDateFormat(jsondate) {
2: jsondate = jsondate.replace("/Date(", "").replace(")/", "");
3: if (jsondate.indexOf("+") > 0) {
4: jsondate = jsondate.substring(0, jsondate.indexOf("+"));
5: }
6: else if (jsondate.indexOf("-") > 0) {
7: jsondate = jsondate.substring(0, jsondate.indexOf("-"));
8: }
9:
10: var date = new Date(parseInt(jsondate, 10));
11: var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
12: var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
13: return date.getFullYear() + "-" + month + "-" + currentDate;
14: }
簡單Demo :
ChangeDateFormat("\/Date(1294499956278+0800)\/");
結果:
四、JSON序列化和反序列化集合、字典、數組的處理
在JSON數據中,所有的集合、字典和數組都表示為數組。
List
1: List
2: {
3: new Person(){ Name="張三", Age=28},
4: new Person(){ Name="李四", Age=25}
5: };
6:
7: string jsonString = JsonHelper.JsonSerializer
- >(list);
序列化結果:
"[{\"Age\":28,\"Name\":\"張三\"},{\"Age\":25,\"Name\":\"李四\"}]"
字典不能直接用於JSON,Dictionary字典轉化為JSON並不是跟原來的字典格式一致,而是形式以Dictionary的Key作為名稱」Key「的值,以Dictionary的Value作為名稱為」Value「的值 。如:
1: Dictionary
2: dic.Add("Name", "張三");
3: dic.Add("Age", "28");
4:
5: string jsonString = JsonHelper.JsonSerializer < Dictionary
序列化結果:
1: "[{\"Key\":\"Name\",\"Value\":\"張三\"},{\"Key\":\"Age\",\"Value\":\"28\"}]"
星期 排序
在寫 access 的星期排序,竟發現無法排序..Orz
查了一下,果然無結果;倒是ms-sql 的解法,順便記錄下來了!
---
MS-SQL 星期排序方法:
1:
select * from tb
order by case 星期 when '星期一' then 1
when '星期二' then 2
when '星期三' then 3
when '星期四' then 4
when '星期五' then 5
when '星期六' then 6
when '星期日' then 7
end
2:
select * from 表
order by charindex(字段, '星期一,星期二,星期三,星期四,星期五')
查了一下,果然無結果;倒是ms-sql 的解法,順便記錄下來了!
---
MS-SQL 星期排序方法:
1:
select * from tb
order by case 星期 when '星期一' then 1
when '星期二' then 2
when '星期三' then 3
when '星期四' then 4
when '星期五' then 5
when '星期六' then 6
when '星期日' then 7
end
2:
select * from 表
order by charindex(字段, '星期一,星期二,星期三,星期四,星期五')
宣告 class 為陣列使用 (json 運用)
參考來源
' Create an array of creature classes Dim creatureArray(10) As creatures Dim i As Integer = 0 ' Load up the array with 10 creatures named MonsterMan0 - MonsterMan9 For i = 0 To 9 Dim mycreature As creatures = New creatures() ' Set his name and his age (all our monsters are clones, so they have the same age! (you could assign whatever data you wanted) mycreature.name = "MonsterMan" & i.ToString mycreature.age = 100 ' Store our copy of the creature into the array of creatures creatureArray(i) = mycreature Next ' Show the name of the 5th monster who is in slot 4 because the array starts at 0, so his name is MonsterMan4MessageBox.Show("The 5th monster is named: " & creatureArray(4).name)
2011年10月28日 星期五
2011年10月27日 星期四
MS-SQL 2008 R2 Express 啟動後,資料庫不見問題
此資料庫不見問題,已在3-5PC發生過
追蹤原因是:安裝 SQL Server Management Studio 後,在服務也是屬自動啟動型
造成開機有機率被 SQL Server Management Studio 先啟動
當被 SQL Server Management Studio 先啟動,就會變成 SQL Server R2 Express 沒有掛上使用者資料庫
---
當初不明原因,還移除重安裝...
追蹤原因是:安裝 SQL Server Management Studio 後,在服務也是屬自動啟動型
造成開機有機率被 SQL Server Management Studio 先啟動
當被 SQL Server Management Studio 先啟動,就會變成 SQL Server R2 Express 沒有掛上使用者資料庫
---
當初不明原因,還移除重安裝...
效能計數器登錄區已損毀
安裝 MS-SQL 2008 R2 Express 時,出現:效能計數器登錄區已損毀
安裝這麼多次以來,還是第一次遇到
此產生原因,因該是原本的MS-SQL 2005 Express 未移除乾淨所造成不一致的主因
參考來源
採用裡面的方法 B,底下操作調整讓它一致後;MS-SQL 2008 R2 Express 即可正常安裝了
安裝這麼多次以來,還是第一次遇到
此產生原因,因該是原本的MS-SQL 2005 Express 未移除乾淨所造成不一致的主因
參考來源
採用裡面的方法 B,底下操作調整讓它一致後;MS-SQL 2008 R2 Express 即可正常安裝了
2011年10月26日 星期三
case when 運用
SELECT DISTINCT bfir_date AS back_date, vendor, mtype AS [type], msize AS size, Case When Substring(cus_name,1,3)="(代)" Then 1 Else 2 End As cus_name FROM dbo_ram
Split 分割字串
2011年10月25日 星期二
2011年10月24日 星期一
在 NET 中使用VB6所製作的DLL檔
參考
--
VB6所製作的DLL檔是屬於 "Unmanaged Code".而C#所使用的是屬於 "Managed Code".因此我們必須將 "Unmanaged Code"轉換成 "Managed Code".
步驟1.
將該欲轉換的DLL檔複製到tlbimp.exe的所在位置,預設是在 "C:\Program Files\Microsoft.NET\SDK\v2.0\Bin"
步驟2.
從 "附屬應用程式" 啟動 "命令提示字元"。在視窗開啟之後,變更目錄到tlbimp.exe的所在位置。
cd C:\Program Files\Microsoft.NET\SDK\v2.0\Bin
步驟3.
執行
c:tlbimp 原始.DLL /o:目的.DLL
執行完成之後會產生"目的.DLL"檔。將這個DLL檔複製到專案的目錄下。
步驟4:
在C#內,以 Add Reference \ .NET Assembly Browser 將DLL檔引入 ,並在檔案的最上方加入
using 剛加入DLL的name space;
--
底下為我的實作,上述引用的說要切到 v2.0\bin 下 ; 是不需要! 直切到 vb6 的 dll 執行 tlbimp 即可
--
--
VB6所製作的DLL檔是屬於 "Unmanaged Code".而C#所使用的是屬於 "Managed Code".因此我們必須將 "Unmanaged Code"轉換成 "Managed Code".
步驟1.
將該欲轉換的DLL檔複製到tlbimp.exe的所在位置,預設是在 "C:\Program Files\Microsoft.NET\SDK\v2.0\Bin"
步驟2.
從 "附屬應用程式" 啟動 "命令提示字元"。在視窗開啟之後,變更目錄到tlbimp.exe的所在位置。
cd C:\Program Files\Microsoft.NET\SDK\v2.0\Bin
步驟3.
執行
c:tlbimp 原始.DLL /o:目的.DLL
執行完成之後會產生"目的.DLL"檔。將這個DLL檔複製到專案的目錄下。
步驟4:
在C#內,以 Add Reference \ .NET Assembly Browser 將DLL檔引入 ,並在檔案的最上方加入
using 剛加入DLL的name space;
--
底下為我的實作,上述引用的說要切到 v2.0\bin 下 ; 是不需要! 直切到 vb6 的 dll 執行 tlbimp 即可
--
dtproperties 資料表
真是神奇的狀況,使用者資料表無:dtproperties
卻自己生出來,原因在資料庫是由MS-SQL 2000 升上來的
在MS-SQL 2008 Express 卻歸在:系統資料表
因在寫異地資料庫檢核的工具,倒是發現此差異
google 後,很多人也產生跟我一樣的狀況問題
刪除不影響運作! (dtproperties,sysdiagrams 2資料表)
卻自己生出來,原因在資料庫是由MS-SQL 2000 升上來的
在MS-SQL 2008 Express 卻歸在:系統資料表
因在寫異地資料庫檢核的工具,倒是發現此差異
google 後,很多人也產生跟我一樣的狀況問題
刪除不影響運作! (dtproperties,sysdiagrams 2資料表)
2011年10月22日 星期六
2011年10月20日 星期四
取檔案 size
方法一:
Dim myFileLength As Long = My.Computer.FileSystem.GetFileInfo("c:\test.txt").Length
方法二:
Dim myFileLength As Long = New System.IO.FileInfo("c:\test.txt").Length
延遲
參考
--
--
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "{開始1} : " + Now.Second.ToString + vbCrLf
delay(5)
TextBox1.Text += "{執行1} : " + Now.Second.ToString + vbCrLf
End Sub
Sub delay(ByVal t As Integer)
Dim Start As Integer = Environment.TickCount()
Dim TimeLast As Integer = t * 1000 ' 要延遲 t 秒,就設為 t *1000
Do
If Environment.TickCount() - Start > TimeLast Then Exit Do
Application.DoEvents()
Loop
End Sub
End Class
--
--
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "{開始1} : " + Now.Second.ToString + vbCrLf
delay(5)
TextBox1.Text += "{執行1} : " + Now.Second.ToString + vbCrLf
End Sub
Sub delay(ByVal t As Integer)
Dim Start As Integer = Environment.TickCount()
Dim TimeLast As Integer = t * 1000 ' 要延遲 t 秒,就設為 t *1000
Do
If Environment.TickCount() - Start > TimeLast Then Exit Do
Application.DoEvents()
Loop
End Sub
End Class
2011年10月19日 星期三
如何取得 MDB 裡面資料表清單
參考
--
--
Dim dbfile As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Nwind.mdb" Dim str As String = dbfile Dim conn As OleDbConnection = New OleDbConnection(str) conn.Open() Dim dt As DataTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"}) conn.Close() For i As Integer = 0 To dt.Rows.Count - 1 Debug.WriteLine(dt.Rows(i)("TABLE_NAME")) Next
2011年10月18日 星期二
DataSet、DataTable、DataRow複製方式
DataSet dsSource = new DataSet(); //來源DataSet
DataTable dtSource = new DataTable(); //來源DataSet
//複製DataSet
DataSet dsTarget = dsSource.Copy(); //複製格式與資料
DataSet dsTarget = dsSource.Clone(); //只複製格式
//複製DataTable
DataTable dtTarget = dtSource.Copy(); //複製格式與資料
DataTable dtTarget = dtSource.Clone(); //只複製格式
//複製DataRow
1 . ImportDataRow方法:public void ImportDataRow( DataRow DataRow);
DataTable dtTarget = dtSource.clone();//必須先複製DataTable的格式
foreach (DataRow dr in dtSource)
dtTarget.ImportDataRow(dr);//dtTarget中添加一個新行,並將dr的值複製進去,要求資料表的格式一樣!
2 自定義複製
dtTarget.Columns.Add ("id");//不需要有一樣的格式,只複製自己需要的欄位!
Object [] myArry = new Object [1];
foreach (DataRow dr in dtSource)
{
DataRow drNew = dtTarget.NewRow();//必須呼叫此方法!
myArry[0] = dr["id"];//如果myArry中沒有來源資料表中的id列的話就會產生錯誤!
drNew.ItemArray = myArry;//ItemArray屬性為Object類型數組,根據程式的需要可以自行複製多個欄位的資料!
dtTarget.Rows.Add(drNew); //必須呼叫此方法!,否則DataRow中的數據將不能顯示!
}
3 LoadDataRow方法:public DataRow LoadDataRow(Object[] values,bool fAcceptChanges);
Object[] newRow = new Object[3];
//設定資料
newRow[0] = "Hello";
newRow[1] = "World";
newRow[2] = "two";
DataRow myRow;
dtTarget.BeginLoadData();
// 將新資料列添加到資料表中
myRow = dtTarget.LoadDataRow(newRow, true);//標誌要設置為true,表示新增資料列
dtTarget.EndLoadData();
DATATABLE複製到另一個DATATABLE
參考來源
---
Dim mynewtable As DataTable = DirectCast(OriginalDataTable, DataTable).Clone
Dim myrows As DataRow() = DirectCast(DataGrid1.DataSource, DataTable).Select(".....")
For Each dr As DataRow In myrows
mynewtable.ImportRow(dr)
Next
---
Dim mynewtable As DataTable = DirectCast(OriginalDataTable, DataTable).Clone
Dim myrows As DataRow() = DirectCast(DataGrid1.DataSource, DataTable).Select(".....")
For Each dr As DataRow In myrows
mynewtable.ImportRow(dr)
Next
comboBox.Items.AddRange
詳細請參考微軟官網
---
AddRange 是陣列字串型態
dim a as string()=new string(){"1","2","3"}
comboBox.Items.AddRange(a)
---
AddRange 是陣列字串型態
dim a as string()=new string(){"1","2","3"}
comboBox.Items.AddRange(a)
2011年10月17日 星期一
File Input/Output
詳細請參考原站,還有更豐富的文章
----
So far we haven’t talked about writing words or sentences to a hard drive or reading from it. This part will guide you through those processes. File streams can be stored in plain text and binary format. There are two types of file streams—sequential-access file and random-access file.
Sequential-Access File
In sequential-access file, you can write data to the file or read data from it sequentially from the beginning of the file to the end and vice versa.
Writing to a sequential-access file
Example:
Imports System.IO 'Don’t forget to import IO package
Module Module1
Sub Main()
Dim SF As New SequentialFile
SF.writingToFile("D:\sequentialfile.txt")
'Note: In this part, we introduce error handling with try..catch..end try block
End Sub
Class SequentialFile
Public Sub writingToFile(ByVal filename As String)
'Open file for writing
Dim fout As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)
'Create StreamWriter tool
Dim fw As New StreamWriter(fout)
'write text to file
fw.WriteLine("Hello World")
'close file
fout.Close()
fw.Close()
End Sub
End Class
End Module
Reading from a sequential-access file
Example:
Imports System.IO 'Don’t forget to import IO package
Module Module1
Sub Main()
Dim SF As New SequentialFile
'reading from file
SF.readingFromFile("D:\sequentialfile.txt")
'Note: In this part, we introduce error handling with try..catch..end try block
End Sub
Class SequentialFile
Public Sub readingFromFile(ByVal filename As String)
Dim fn As FileStream
Dim fr As StreamReader
Try
'Open file for reading
fn = New FileStream(filename, FileMode.Open, FileAccess.Read)
'Create reader tool
fr = New StreamReader(fn)
'Read the content of file
Dim filecontent As String = fr.ReadToEnd
Console.WriteLine(filecontent)
Console.ReadLine()
Catch e As IOException
MsgBox(e.Message)
End Try
'Close file
fr.Close()
fn.Close()
End Sub
End Class
End Module
2011年10月16日 星期日
SqlDataReader 取筆數
參考
--
只有這一招是一次完成動作
--
如果你想要取得DaraReader,又要馬上知道所有的列數,
建議你可以利用Stored Procedure的方式達成。
以下為範例:
Create PROCEDURE MyJob_sp_ReturnMyData
(
@UserName varchar(20),
@TotalRecs int output
)
AS
Select * From MyTableName Where UserName = @UserName
Select @TotalRecs = Count(0) From MyTaleName Where UserName = @UserName
然後我們在前端可以這樣做:
//建立Command物件
OleDbCommand cmd = new ("MyJob_sp_ReturnMyData", DBConnstr);
cmd.CommandType = CommandType.StoredProcedure; // 這邊請注意要設定
//加入參數
OleDbParameter paUserName = new OleDbParameter("@UserName", OleDbType.VarChar, 20);
OleDbParameter paTotalCount = new OleDbParameter("@TotalRecs" , OleDbType.integer);
paTotalCount.Direction = ParameterDirection.Output; //這邊請注意要設定
paUserName.Value = "David";
cmd.Parameters.Add(paUserName);
cmd.Parameters.Add(paTotalCount);
//執行
int TotalCount = 0;
try
{
OleDbDataReader dr = cmd.ExecuteRader();
TotalCount = paTotalCount.Value; //取得輸出的列數
}
catch
{
// do something
}
finally
{
//do something like closing conntion and datareader
}
process sqlcmd
c#:
string tmpFile = Path.GetTempFileName();
string argument = string.Format(@" -S {0} -d {1} -i ""{2}"" -o ""{3}""",
ServerName, DatabaseName, fileName, tmpFile);
// append user/password if not use integrated security
if (!connection.IsIntegratedSecurity)
argument += string.Format(" -U {0} -P {1}", User, Password);
var process = Process.Start("sqlcmd.exe", argument);
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
while (true)
{
// wait for the process exits. The WaitForExit() method doesn't work
if (process.HasExited)
break;
Thread.Sleep(500);
}
vbnet:
Dim tmpFile As String = Path.GetTempFileName
Dim argument As String = String.Format(" -S {0} -d {1} -i """"{2}"""" -o """"{3}""""", ServerName, DatabaseName, fileName, tmpFile)
' append user/password if not use integrated security
If Not connection.IsIntegratedSecurity Then
argument = (argument + String.Format(" -U {0} -P {1}", User, Password))
End If
Dim process As var = Process.Start("sqlcmd.exe", argument)
process.StartInfo.UseShellExecute = false
process.StartInfo.CreateNoWindow = true
process.Start
While true
' wait for the process exits. The WaitForExit() method doesn't work
If process.HasExited Then
Exit While
End If
Thread.Sleep(500)
End While
string tmpFile = Path.GetTempFileName();
string argument = string.Format(@" -S {0} -d {1} -i ""{2}"" -o ""{3}""",
ServerName, DatabaseName, fileName, tmpFile);
// append user/password if not use integrated security
if (!connection.IsIntegratedSecurity)
argument += string.Format(" -U {0} -P {1}", User, Password);
var process = Process.Start("sqlcmd.exe", argument);
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
while (true)
{
// wait for the process exits. The WaitForExit() method doesn't work
if (process.HasExited)
break;
Thread.Sleep(500);
}
vbnet:
Dim tmpFile As String = Path.GetTempFileName
Dim argument As String = String.Format(" -S {0} -d {1} -i """"{2}"""" -o """"{3}""""", ServerName, DatabaseName, fileName, tmpFile)
' append user/password if not use integrated security
If Not connection.IsIntegratedSecurity Then
argument = (argument + String.Format(" -U {0} -P {1}", User, Password))
End If
Dim process As var = Process.Start("sqlcmd.exe", argument)
process.StartInfo.UseShellExecute = false
process.StartInfo.CreateNoWindow = true
process.Start
While true
' wait for the process exits. The WaitForExit() method doesn't work
If process.HasExited Then
Exit While
End If
Thread.Sleep(500)
End While
datagridview to datatable
參考
--
Dim RptTable As New DataTable
RptTable.Columns.Add("機台號碼")
RptTable.Columns.Add("模號")
RptTable.Columns.Add("模數")
RptTable.Columns.Add("料別")
RptTable.Columns.Add("生產數")
RptTable.Columns.Add("訂單號碼")
RptTable.Columns.Add("生產者")
RptTable.Columns.Add("製程編號")
RptTable.Columns.Add("不良數")
RptTable.Columns.Add("單號")
RptTable.Columns.Add("移交數量")
RptTable.Columns.Add("開始日期")
RptTable.Columns.Add("生產加總數")
--
Dim RptTable As New DataTable
RptTable = ds.Tables("abc").Copy
--
Dim RptTable As New DataTable
RptTable.Columns.Add("機台號碼")
RptTable.Columns.Add("模號")
RptTable.Columns.Add("模數")
RptTable.Columns.Add("料別")
RptTable.Columns.Add("生產數")
RptTable.Columns.Add("訂單號碼")
RptTable.Columns.Add("生產者")
RptTable.Columns.Add("製程編號")
RptTable.Columns.Add("不良數")
RptTable.Columns.Add("單號")
RptTable.Columns.Add("移交數量")
RptTable.Columns.Add("開始日期")
RptTable.Columns.Add("生產加總數")
--
Dim RptTable As New DataTable
RptTable = ds.Tables("abc").Copy
2011年10月15日 星期六
toolstripcombobox datasource
toolStripComboBox.ComboBox.DataSource = datatable;
toolStripComboBox.ComboBox.ValueMember = "ItemID";
toolStripComboBox.ComboBox.DisplayMember = "ItemName";
2011年10月14日 星期五
使用 Stored Procedures
參考來源
---
alling Stored Procedure
Hope everyone have used SQLCommand / OLEDB Command objects in .NET. Here we can call stored procedures in two different forms, one without using parameter objects which is not recommended for conventional development environments, the other one is the familiar model of using Parameters.
In the first method you can call the procedure using Exec command followed by the procedure name and the list of parameters, which doesn’t need any parameters.
Example:
Dim SQLCon As New SqlClient.SqlConnection
SQLCon.ConnectionString = "Data Source=Server;User ID=User;Password=Password;"
SQLCon.Open()
Calling Stored Procedures with Exec command
SQLCmd.CommandText = "Exec SelectRecords 'Test', 'Test', 'Test'"
SQLCmd.Connection = SQLCon 'Active Connection
The second most conventional method of calling stored procedures is to use the parameter objects and get the return values using them. In this method we need to set the “SQLCommandType” to “StoredProcedure” remember you need to set this explicitly as the the default type for SQLCommand is SQLQuery”.
Here is an example to call a simple stored procedure.
Example - I (A Stored Procedure Returns Single Value)
In order to get XML Results from the Stored Procedure you need to first ensure that your stored procedure is returning a valid XML. This can be achieved using FOR XML [AUTO | RAW | EXPLICIT] clause in the select statements. You can format XML using EXPLICIT Keyword, you need to alter your Query accordingly
'Set up Connection object and Connection String for a SQL Client
Dim SQLCon As New SqlClient.SqlConnection
SQLCon.ConnectionString = "Data Source=Server;User ID=User;Password=Password;"
SQLCon.Open()
SQLCmd.CommandText = "SelectRecords" ' Stored Procedure to Call
SQLCmd.CommandType = CommandType.StoredProcedure 'Setup Command Type
SQLCmd.Connection = SQLCon 'Active Connection
The procedure can be called by adding Parameters in at least two different methods, the simplest way to add parameters and respective values is using
SQLCmd.Parameters.AddWithValue("S_Mobile", "Test")
SQLCmd.Parameters.AddWithValue("S_Mesg", "Test")
SQLCmd.Parameters.AddWithValue("LastMsgID", "")
In this above method, you doesn’t necessarily know the actually data type that you had in your procedure and all parameters are validated according to the type declared in your procedure but only thing is all the validations will occur in SQL and not in your client code.
We still need to declare the last parameter as Output and we need to do that explicitly as the default type is Input. So here we are going to declare the last parameter as Output by
SQLCmd.Parameters("LastMsgID").Direction = ParameterDirection.Outputfs
If you want to declare parameters properly then you need to use the below method to add all the parameters with its data type, direction. Also if you are using stored procedures to update all the rows in a dataset then you need to declare parameters in the below fashion and give SouceColumn value as the Column name in the DataTable.
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("S_Mobile", SqlDbType.VarChar, 10, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "91000000000"))
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("S_Mesg", SqlDbType.VarChar, 160, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Calling Stored Procedures from VB.NET"))
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("LastMsgID", SqlDbType.BigInt, 5, ParameterDirection.Output, False, 5, 0, "", DataRowVersion.Current, 0))
' The Above Procedure has two input parameters and one output parameter you can notice the same in the “Parameter Direction”
SQLCmd.ExecuteNonQuery() 'We are executing the procedure here by calling Execute Non Query.
MsgBox(SQLCmd.Parameters("LastMsgID").Value) 'You can have the returned value from the stored procedure from this statement. Its all similar to ASP / VB as the only difference is the program structure.
Example - II (Stored Procedure to get Table Result Set)
In order to get the result sets from the stored procedure, the best way is to use a DataReader to get the results. In this example we are getting the results from the Stored Procedure and filling the same in a DataTable.
Here we need to additionally declare a SQLDataReader and DataTable
Dim SQLDBDataReader As SqlClient.SqlDataReader
Dim SQLDataTable As New DataTable
SQLCmd.CommandText = "GetAuthors"
SQLCmd.CommandType = CommandType.StoredProcedure
SQLCmd.Connection = SQLCon
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("AuthorName", SqlDbType.VarChar, 100, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Y%")) SQLDBDataReader = SQLCmd.ExecuteReader() SQLDataTable.Columns.Add("AuthorName", GetType(Int32), "") SQLDataTable.Columns.Add("AuthorLocation", GetType(String), "")
Dim FieldValues(1) As Object 'A Temporary Variable to retrieve all columns in a row and fill them in Object array
While (SQLDBDataReader.Read)
SQLDBDataReader.GetValues(FieldValues)
SQLDataTable.Rows.Add(FieldValues)
End While
Example - III (Calling Simple Stored Procedure to get XML Result Set)
In order to get XML Results from the Stored Procedure you need to first ensure that your stored procedure is returning a valid XML. This can be achieved using FOR XML [AUTO | RAW | EXPLICIT] clause in the select statements. You can format XML using EXPLICIT Keyword, you need to alter your Query accordingly.
CREATE PROCEDURE GetRecordsXML (@AuthorName varchar(100))
AS
Select Author_ID, Author_Name, Author_Location Where Author_Name LIKE @AuthorName from Authors FOR XML AUTO
RETURN
When you use the above procedure you can get XML Results with TableName as Element and Fields as Attributes
Dim SQLXMLReader As Xml.XmlReader
SQLCmd.CommandText = "GetAuthorsXML"
SQLCmd.CommandType = CommandType.StoredProcedure
SQLCmd.Connection = SQLCon
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("AuthorName", SqlDbType.VarChar, 100, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Y%"))
SQLDBDataReader = SQLCmd.ExecuteReader()
SQLXMLReader = SQLCmd.ExecuteXmlReader()
While (SQLXMLReader.Read)
MsgBox(SQLXMLReader.ReadOuterXml)
End While
You can further process this XML or write XSL to display results in a formatted manner. But in order to get formatted XML Results, we need to use EXPLICIT case which we can see in our next article on SQL Queries & XML.
---
alling Stored Procedure
Hope everyone have used SQLCommand / OLEDB Command objects in .NET. Here we can call stored procedures in two different forms, one without using parameter objects which is not recommended for conventional development environments, the other one is the familiar model of using Parameters.
In the first method you can call the procedure using Exec command followed by the procedure name and the list of parameters, which doesn’t need any parameters.
Example:
Dim SQLCon As New SqlClient.SqlConnection
SQLCon.ConnectionString = "Data Source=Server;User ID=User;Password=Password;"
SQLCon.Open()
Calling Stored Procedures with Exec command
SQLCmd.CommandText = "Exec SelectRecords 'Test', 'Test', 'Test'"
SQLCmd.Connection = SQLCon 'Active Connection
The second most conventional method of calling stored procedures is to use the parameter objects and get the return values using them. In this method we need to set the “SQLCommandType” to “StoredProcedure” remember you need to set this explicitly as the the default type for SQLCommand is SQLQuery”.
Here is an example to call a simple stored procedure.
Example - I (A Stored Procedure Returns Single Value)
In order to get XML Results from the Stored Procedure you need to first ensure that your stored procedure is returning a valid XML. This can be achieved using FOR XML [AUTO | RAW | EXPLICIT] clause in the select statements. You can format XML using EXPLICIT Keyword, you need to alter your Query accordingly
'Set up Connection object and Connection String for a SQL Client
Dim SQLCon As New SqlClient.SqlConnection
SQLCon.ConnectionString = "Data Source=Server;User ID=User;Password=Password;"
SQLCon.Open()
SQLCmd.CommandText = "SelectRecords" ' Stored Procedure to Call
SQLCmd.CommandType = CommandType.StoredProcedure 'Setup Command Type
SQLCmd.Connection = SQLCon 'Active Connection
The procedure can be called by adding Parameters in at least two different methods, the simplest way to add parameters and respective values is using
SQLCmd.Parameters.AddWithValue("S_Mobile", "Test")
SQLCmd.Parameters.AddWithValue("S_Mesg", "Test")
SQLCmd.Parameters.AddWithValue("LastMsgID", "")
In this above method, you doesn’t necessarily know the actually data type that you had in your procedure and all parameters are validated according to the type declared in your procedure but only thing is all the validations will occur in SQL and not in your client code.
We still need to declare the last parameter as Output and we need to do that explicitly as the default type is Input. So here we are going to declare the last parameter as Output by
SQLCmd.Parameters("LastMsgID").Direction = ParameterDirection.Outputfs
If you want to declare parameters properly then you need to use the below method to add all the parameters with its data type, direction. Also if you are using stored procedures to update all the rows in a dataset then you need to declare parameters in the below fashion and give SouceColumn value as the Column name in the DataTable.
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("S_Mobile", SqlDbType.VarChar, 10, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "91000000000"))
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("S_Mesg", SqlDbType.VarChar, 160, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Calling Stored Procedures from VB.NET"))
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("LastMsgID", SqlDbType.BigInt, 5, ParameterDirection.Output, False, 5, 0, "", DataRowVersion.Current, 0))
' The Above Procedure has two input parameters and one output parameter you can notice the same in the “Parameter Direction”
SQLCmd.ExecuteNonQuery() 'We are executing the procedure here by calling Execute Non Query.
MsgBox(SQLCmd.Parameters("LastMsgID").Value) 'You can have the returned value from the stored procedure from this statement. Its all similar to ASP / VB as the only difference is the program structure.
Example - II (Stored Procedure to get Table Result Set)
In order to get the result sets from the stored procedure, the best way is to use a DataReader to get the results. In this example we are getting the results from the Stored Procedure and filling the same in a DataTable.
Here we need to additionally declare a SQLDataReader and DataTable
Dim SQLDBDataReader As SqlClient.SqlDataReader
Dim SQLDataTable As New DataTable
SQLCmd.CommandText = "GetAuthors"
SQLCmd.CommandType = CommandType.StoredProcedure
SQLCmd.Connection = SQLCon
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("AuthorName", SqlDbType.VarChar, 100, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Y%")) SQLDBDataReader = SQLCmd.ExecuteReader() SQLDataTable.Columns.Add("AuthorName", GetType(Int32), "") SQLDataTable.Columns.Add("AuthorLocation", GetType(String), "")
Dim FieldValues(1) As Object 'A Temporary Variable to retrieve all columns in a row and fill them in Object array
While (SQLDBDataReader.Read)
SQLDBDataReader.GetValues(FieldValues)
SQLDataTable.Rows.Add(FieldValues)
End While
Example - III (Calling Simple Stored Procedure to get XML Result Set)
In order to get XML Results from the Stored Procedure you need to first ensure that your stored procedure is returning a valid XML. This can be achieved using FOR XML [AUTO | RAW | EXPLICIT] clause in the select statements. You can format XML using EXPLICIT Keyword, you need to alter your Query accordingly.
CREATE PROCEDURE GetRecordsXML (@AuthorName varchar(100))
AS
Select Author_ID, Author_Name, Author_Location Where Author_Name LIKE @AuthorName from Authors FOR XML AUTO
RETURN
When you use the above procedure you can get XML Results with TableName as Element and Fields as Attributes
Dim SQLXMLReader As Xml.XmlReader
SQLCmd.CommandText = "GetAuthorsXML"
SQLCmd.CommandType = CommandType.StoredProcedure
SQLCmd.Connection = SQLCon
SQLCmd.Parameters.Add(New SqlClient.SqlParameter("AuthorName", SqlDbType.VarChar, 100, ParameterDirection.Input, False, 30, 0, "", DataRowVersion.Current, "Y%"))
SQLDBDataReader = SQLCmd.ExecuteReader()
SQLXMLReader = SQLCmd.ExecuteXmlReader()
While (SQLXMLReader.Read)
MsgBox(SQLXMLReader.ReadOuterXml)
End While
You can further process this XML or write XSL to display results in a formatted manner. But in order to get formatted XML Results, we need to use EXPLICIT case which we can see in our next article on SQL Queries & XML.
2011年10月13日 星期四
MS SQL DataTypes QuickRef
參考來源
Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.
CHARACTER_OCTET_LENGTH contains the field's length in bytes.
Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively.
Finally, IS_NULLABLE denotes whether the field may contain null values.
ADO OpenSchema adSchemaProcedureParameters=26
The ADO OpenSchema method returns incomplete info in the DATA_TYPE column for many data types.
The COLUMN_FLAGS field is not available.
The TYPE_NAME column returned for stored procedure parameters can be used for accurate type information.
The smallmoney NUMERIC_PRECISION is less than 19, distinguishing it from money.
The smalldatetime datatype cannot be distinguished from datetime (but the former is of limited usefulness given the range, so is perhaps best avoided).
Defaults are indicated by PARAMETER_HASDEFAULT and available in PARAMETER_DEFAULT.
PARAMETER_TYPE is the direction of the parameter: adParamInput=1, adParamInputOutput=3, adParamOutput=2, adParamReturnValue=4, or adParamUnknown=0.
Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.
CHARACTER_OCTET_LENGTH contains the field's length in bytes.
Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively.
Finally, IS_NULLABLE denotes whether the field may contain null values.
Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.
CHARACTER_OCTET_LENGTH contains the field's length in bytes.
Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively.
Finally, IS_NULLABLE denotes whether the field may contain null values.
ADO OpenSchema adSchemaProcedureParameters=26
The ADO OpenSchema method returns incomplete info in the DATA_TYPE column for many data types.
The COLUMN_FLAGS field is not available.
The TYPE_NAME column returned for stored procedure parameters can be used for accurate type information.
The smallmoney NUMERIC_PRECISION is less than 19, distinguishing it from money.
The smalldatetime datatype cannot be distinguished from datetime (but the former is of limited usefulness given the range, so is perhaps best avoided).
Defaults are indicated by PARAMETER_HASDEFAULT and available in PARAMETER_DEFAULT.
PARAMETER_TYPE is the direction of the parameter: adParamInput=1, adParamInputOutput=3, adParamOutput=2, adParamReturnValue=4, or adParamUnknown=0.
Character (and binary) field lengths are given in CHARACTER_MAXIMUM_LENGTH.
CHARACTER_OCTET_LENGTH contains the field's length in bytes.
Numeric column precision and scale are given by NUMERIC_PRECISION and NUMERIC_SCALE, respectively.
Finally, IS_NULLABLE denotes whether the field may contain null values.
Convert Domain Name to I.P Address
參考
---
Imports System.Net
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
For Each address As IPAddress In
Dns.GetHostAddresses("www.devcurry.com")
Response.Write(address.ToString())
Next address
End Sub
---
Imports System.Net
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
For Each address As IPAddress In
Dns.GetHostAddresses("www.devcurry.com")
Response.Write(address.ToString())
Next address
End Sub
SQL Server中的varchar(max)、nvarchar(max) 和varbinary(max)
SQL Server中的varchar(max)、nvarchar(max) 和varbinary(max)
varchar(max) text* [ 2^30 - 1 (1,073,741,823) characters ]
nvarchar(max) ntext* [ 2^31-1 (2,147,483,647) characters/bytes ]
varbinary(max) image [ 2^31-1 (2,147,483,647) bytes ]
2011年10月12日 星期三
Read xml content to DataSet
參考1 (不錯的blog)
------------
Imports System.Xml
Imports System.IO
Dim ds As New DataSet
' use filestream class to read xml content.
Dim streamRead As New System.IO.FileStream("C\test.xml", _
System.IO.FileMode.Open)
'Dataset can read content from FileStream.
ds.ReadXml(streamRead)
' Bind data to your control.
DataGridView1.DataSource = ds.Tables(0)
' Close FileStream object
streamRead.Close()
ssms set implicit_transactions 的影響
不知在個部落格上看到有啟用:set implicit_transactions
說什 在 ssms 內 update , xxx 須交易模式 ; 才會生效 , 感覺不錯..就跟著設定了
結果,今天奇怪了;在 建 store procedure 時,怎老建不出來(1x次)
才突然想起,ssms 前陣子有動過參數;這才把這參數關閉
總算可建 store procedure 了 ... 實在,經驗告訴我;文章參考就好..不要輕易搞累自己!
說什 在 ssms 內 update , xxx 須交易模式 ; 才會生效 , 感覺不錯..就跟著設定了
結果,今天奇怪了;在 建 store procedure 時,怎老建不出來(1x次)
才突然想起,ssms 前陣子有動過參數;這才把這參數關閉
總算可建 store procedure 了 ... 實在,經驗告訴我;文章參考就好..不要輕易搞累自己!
2011年10月11日 星期二
ILMerge (將多的 .NET 組件合併成單一組件)
當 .NET 專案開發越來越多的情況下,通常會有一大堆組件的情況,
微軟提供一套 ILMerge 免費工具可以協助你將多個組件合併成單一個 .NET 組件,
有效減少部署檔案的數量以及增加部署的彈性。
--
微軟官網_ILMerge
ILMerge_GUI(界面)
SQL SERVER-取得資料庫所有資料表,取得資料表所有欄位
參考2
----
SELECT * FROM INFORMATION_SCHEMA.Tables
SELECT * FROM INFORMATION_SCHEMA.Columns Where Table_Name = 'TableName'
SELECT 資料行名稱=COLUMN_Name ,資料型別=DATA_TYPE,長度=CHARACTER_MAXIMUM_LENGTH ,是否允許NULL=IS_NULLABLE , 預設值=COLUMN_DEFAULT FROM INFORMATION_SCHEMA.Columns Where Table_Name = 'TableName'
SELECT
a.TABLE_NAME as 表格名稱,
b.COLUMN_NAME as 欄位名稱,
b.DATA_TYPE as 資料型別,
b.CHARACTER_MAXIMUM_LENGTH as 最大長度,
b.COLUMN_DEFAULT as 預設值,
b.IS_NULLABLE as 允許空值,
(
SELECT
value
FROM
fn_listextendedproperty (NULL, 'schema', 'dbo', 'table', a.TABLE_NAME, 'column', default)
WHERE
name='MS_Description'
and objtype='COLUMN'
and objname Collate Chinese_Taiwan_Stroke_CI_AS = b.COLUMN_NAME
) as 欄位備註
FROM
INFORMATION_SCHEMA.TABLES a
LEFT JOIN INFORMATION_SCHEMA.COLUMNS b ON ( a.TABLE_NAME=b.TABLE_NAME )
WHERE
TABLE_TYPE='BASE TABLE'
ORDER BY
a.TABLE_NAME, ordinal_position
---
更完整的: 請參考來源
SELECT Cols.TABLE_NAME,
Cols.COLUMN_NAME,
Cols.ORDINAL_POSITION,
Cols.DATA_TYPE,
Cols.NUMERIC_PRECISION,
Cols.NUMERIC_SCALE,
Cols.IS_NULLABLE,
Cols.CHARACTER_MAXIMUM_LENGTH,
COLUMNPROPERTY(object_id(Cols.TABLE_NAME), Cols.COLUMN_NAME, 'IsIdentity') AS IsIdentity,
( SELECT COUNT(KCU.COLUMN_NAME)
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC ON KCU.TABLE_NAME = TC.TABLE_NAME
AND KCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME
AND TC.CONSTRAINT_TYPE = 'PRIMARY KEY'
WHERE KCU.TABLE_NAME = Cols.TABLE_NAME
AND KCU.COLUMN_NAME = Cols.COLUMN_NAME
) AS IsIndex
FROM [INFORMATION_SCHEMA].[COLUMNS] Cols
ORDER BY Cols.TABLE_NAME,
Cols.ORDINAL_POSITION
2011年10月7日 星期五
DataTable store 排序
參考
c#:
dataview v=dt.defaultview;
v.sort="columnName DESC";
dt=v.toTable();
vb:
dim v as dataview=dt.defaultview
v.sort="columnName DESC"
dt=v.toTable()
2011年10月5日 星期三
sql 左聯結並取主表群組筆數
弄了1x分鐘,總算跑出來;記錄起來:
(重點在promo_id=M.promo_id)
--
SELECT D.promo_id,D.prod_bar,
(select COUNT(promo_id) from D where promo_id=M.promo_id) as cc
FROM D LEFT OUTER JOIN
M ON D.promo_id = M.promo_id
WHERE ('2011/10/5' BETWEEN M.promo_sdate AND M.promo_edate)
and D.prod_bar='4710008211013'
(重點在promo_id=M.promo_id)
--
SELECT D.promo_id,D.prod_bar,
(select COUNT(promo_id) from D where promo_id=M.promo_id) as cc
FROM D LEFT OUTER JOIN
M ON D.promo_id = M.promo_id
WHERE ('2011/10/5' BETWEEN M.promo_sdate AND M.promo_edate)
and D.prod_bar='4710008211013'
2011年10月4日 星期二
SQL 語法能否同時取最大值與顯示資料筆數
不錯的 t-sql 收藏
--
參考來源
--
我的資料庫中有一個 Table 如下
產品編號 所在樓層
A001 5
A001 4
A001 3
A002 5
A002 3
A003 4
A003 2
A003 1
我希望能用 GridView 查詢出以下的結果
產品編號 所在最高樓層 資料筆數
A001 5 3
A002 5 2
A003 4 3
--
您可以參考下列語法:
select 產品編號,
(select MAX(所在樓層) from table1 where 產品編號= tb.產品編號) as 所在最高樓層 ,
(Select COUNT(所在樓層) from table1 where 產品編號= tb.產品編號) as 資料筆數,
(Select 負責人 from table1 where 產品編號=tb.產品編號 and 所在樓層 = (select MAX(所在樓層) from table1 where 產品編號= tb.產品編號 )) as 最高樓層負責人
from table1 as tb group by 產品編號
2011年10月3日 星期一
有關多執行緒與委派
跟大家分享一下
現在我做了一個主程式 Form1 程式如下(Form1上有一個ProgressBar1)
程式主要是從Class裡面引發事件,之後傳回值給主程式來利用
複製內容到剪貼板
代碼:
Public Class Form1
Dim WithEvents C As New Class1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = 100
End Sub
Private Sub asdada(ByVal I As Int32) Handles C.EV
ProgressBar1.Value = I
'Me.BeginInvoke(New DelegateHelpBar(AddressOf ADD), New Object() {I})
End Sub
一個Class 程式碼如下
複製內容到剪貼板
代碼:
Public Class Class1
Public Event EV(ByVal S As Int32)
Private T As Timers.Timer
Private Count As Int32 = 0
Public Sub New()
T = New Timers.Timer
T.Interval = 1000
AddHandler T.Elapsed, AddressOf T_Tick
T.Enabled = True
End Sub
Private Sub T_Tick(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
RaiseEvent EV(Count)
Count += 1
End Sub
當你在VS2005裡面執行(debug)之後會有錯誤 "跨執行緒作業無效: 存取控制項 'ProgressBar1' 時所使用的執行緒與建立控制項的執行緒不同。"
不能執行,但是按下建置之後到Release的資料夾裡面直接執行"執行檔"之後,是可以動作的,可以看到ProgressBar1的值有在增加..
到這裡相關可以參考
http://forums.microsoft.com/msdn-cht/ShowPost.aspx?PostID=335818&SiteID=14
來了解為甚麼以及解法
另外,附帶一提,委派的作法(參考璉大的文章把Form1的程式改成如下,Debug就可以正常執行了)
原文http://forums.microsoft.com/msdn-cht/ShowPost.aspx?PostID=968617&SiteID=14
複製內容到剪貼板
代碼:
Public Class Form1
Dim WithEvents C As New Class1
Delegate Sub DelegateHelpBar(ByVal X As Int32)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = 100
End Sub
Private Sub asdada(ByVal I As Int32) Handles C.EV
Me.BeginInvoke(New DelegateHelpBar(AddressOf ADD), New Object() {I})
End Sub
Private Sub ADD(ByVal X As Int32)
ProgressBar1.Value = X
End Sub
End Class
2011年10月2日 星期日
vbnet timer 每10秒執行一次
引入下列命名空间:
System
System.Threading
使用 System.Threading.Timer 类,为使用VB.NET Timer需要如下创建一个实例:
Public Sub StartTimer()
Dim tcb As New TimerCallback(AddressOf Me.TimerMethod)
Dim objTimer As Timer
objTimer = New Timer(tcb, Nothing,TimeSpan.FromSeconds(5),TimeSpan.FromSeconds(10))
End Sub
Public Sub TimerMethod(ByVal state As Object)
MsgBox("The Timer invoked this method.")
End Sub
在VB中實現延時(等待)的幾種方法
在程序流程中经常要延时一段时间后再继续往下执行,在VB中常用的有以下几种方法(因为Timer控件打乱了程序的流程所以一般不用它):
1.使用Windows API函数Sleep
新建一个工程,添加一个TextBox控件和一个CommandButton控件,再将以下代码复制到代码窗口:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Text1 = "sleep begin"
Sleep 3000
Text1 = "sleep end"
End Sub
按F5执行,按下Command1按钮,程序停止执行,3秒钟内不对用户的操作做出反应,并且Text1里的内容并没有发生改变。这是怎么回事呢?原来,Sleep函数功能是将调用它的进程挂起dwMilliseconds毫秒时间,在这段时间内,此进程不对用户操作做出反应,程序中虽然将Text1的Text属性改成Sleep begin,但还没等完成对屏幕的更新进程就被挂起了,对用户来说程序象是死机一样。所以这种方法虽然简单,但并不适用。
2.使用Timer()函数
这是用的最多的一种方法,也是在VB联机手册中所推荐的。添加一个CommandButton控件,再将以下代码添加到代码窗口中:
Private Sub Command2_Click()
Dim Savetime As Single
Text1 = "Timer begin"
Savetime = Timer '记下开始的时间
While Timer < Savetime + 5 '循环等待
DoEvents '转让控制权,以便让操作系统处理其它的事件
Wend
Text1 = "Timer ok"
End Sub
这种方法虽然也很简单,但却有有一个致命缺陷,那就是Timer函数返回的是从午夜开始到现在经过的秒数。所以Timer返回的最大值也只是60*60*24-1秒,如果从一天的23:59:58秒开始计时等待5秒,那么程序会永远地循环下去。要进行改良,就要加上判断是否又开始了新的一天,那岂不是太麻烦。下面给大家推荐另一个Windows API函数。
3.使用Windows API函数timeGetTime()
timeGetTime函数没有参数,返回值是从开机到现在所经历的毫秒数,这个毫秒数是非周期性递增的,所以不会出现Timer()函数出现的问题,而且这种方法的精确性高于上一种方法。添加一个CommandButton控件,再将以下代码添加到代码窗口中:
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Sub Command3_Click()
Dim Savetime As Double
Text1 = "timeGetTime begin"
Savetime = timeGetTime '记下开始时的时间
While timeGetTime < Savetime + 5000 '循环等待
DoEvents '转让控制权,以便让操作系统处理其它的事件
Wend
Text1 = "timeGetTime end"
End Sub
按F5执行程序,按这几个按钮,您可以感受一下这几种方法的优劣。
1.使用Windows API函数Sleep
新建一个工程,添加一个TextBox控件和一个CommandButton控件,再将以下代码复制到代码窗口:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Text1 = "sleep begin"
Sleep 3000
Text1 = "sleep end"
End Sub
按F5执行,按下Command1按钮,程序停止执行,3秒钟内不对用户的操作做出反应,并且Text1里的内容并没有发生改变。这是怎么回事呢?原来,Sleep函数功能是将调用它的进程挂起dwMilliseconds毫秒时间,在这段时间内,此进程不对用户操作做出反应,程序中虽然将Text1的Text属性改成Sleep begin,但还没等完成对屏幕的更新进程就被挂起了,对用户来说程序象是死机一样。所以这种方法虽然简单,但并不适用。
2.使用Timer()函数
这是用的最多的一种方法,也是在VB联机手册中所推荐的。添加一个CommandButton控件,再将以下代码添加到代码窗口中:
Private Sub Command2_Click()
Dim Savetime As Single
Text1 = "Timer begin"
Savetime = Timer '记下开始的时间
While Timer < Savetime + 5 '循环等待
DoEvents '转让控制权,以便让操作系统处理其它的事件
Wend
Text1 = "Timer ok"
End Sub
这种方法虽然也很简单,但却有有一个致命缺陷,那就是Timer函数返回的是从午夜开始到现在经过的秒数。所以Timer返回的最大值也只是60*60*24-1秒,如果从一天的23:59:58秒开始计时等待5秒,那么程序会永远地循环下去。要进行改良,就要加上判断是否又开始了新的一天,那岂不是太麻烦。下面给大家推荐另一个Windows API函数。
3.使用Windows API函数timeGetTime()
timeGetTime函数没有参数,返回值是从开机到现在所经历的毫秒数,这个毫秒数是非周期性递增的,所以不会出现Timer()函数出现的问题,而且这种方法的精确性高于上一种方法。添加一个CommandButton控件,再将以下代码添加到代码窗口中:
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Sub Command3_Click()
Dim Savetime As Double
Text1 = "timeGetTime begin"
Savetime = timeGetTime '记下开始时的时间
While timeGetTime < Savetime + 5000 '循环等待
DoEvents '转让控制权,以便让操作系统处理其它的事件
Wend
Text1 = "timeGetTime end"
End Sub
按F5执行程序,按这几个按钮,您可以感受一下这几种方法的优劣。
2011年10月1日 星期六
Windows API Code Pack for .NET Framework
Windows® API Code Pack for Microsoft® .NET Framework
--- 包含項目列表(詳細請參考官網): Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars Windows Shell Windows 7 Libraries Windows Shell Search API support Explorer Browser Control A hierarchy of Shell Namespace entities Windows Shell property system Drag and Drop for Shell Objects Windows Vista and Windows 7 Common File Dialogs, including custom controls Known Folders and non-file system containers Shell Object Watcher Shell Extensions API support DirectX Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs Windows Vista and Windows 7 Task Dialogs Sensor Platform APIs Extended Linguistic Services APIs Power Management APIs Application Restart and Recovery APIs Network List Manager APIs Command Link control and System defined Shell icons
--- 包含項目列表(詳細請參考官網): Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars Windows Shell Windows 7 Libraries Windows Shell Search API support Explorer Browser Control A hierarchy of Shell Namespace entities Windows Shell property system Drag and Drop for Shell Objects Windows Vista and Windows 7 Common File Dialogs, including custom controls Known Folders and non-file system containers Shell Object Watcher Shell Extensions API support DirectX Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs Windows Vista and Windows 7 Task Dialogs Sensor Platform APIs Extended Linguistic Services APIs Power Management APIs Application Restart and Recovery APIs Network List Manager APIs Command Link control and System defined Shell icons
訂閱:
文章 (Atom)