2009年2月24日 星期二

ORA-12705 Oracle 問題解決方式

用 C# 寫了一支表單程式,將資料丟上 Oracle 資料庫,結果出了問題。

ORA-12705: Cannot access NLS data files or invalid environment specified


詳細的錯誤細節就不說了,爬了很多的文,也一一確認,最後發現是 本身電腦已經有安裝 Oracle Database

原本已安裝 Oracle database 9
本次預定連線至 Oracle database 10i

解決方式:
將 \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE 內找出 NLS_LANG 子機碼

預設是 NA 的值,將 NLS_LANG 變更名稱 --> NLS_LANG2  即可。

也擔心原先 Oracle database 9 的不能跑,試跑了一下。。竟然OK。。

果然有效阿!!! 真好。



C# 字串的語法

字串處理應該是 最常用的吧,最近開始接觸到了,把一些有需要的集中在一起。

例如以下.

string debug_sn = listBox2.SelectedItem.ToString(); //把Listbox2 裡面選到的項目 送到 debug_sn 的變數里面
if (debug_sn.StartsWith("F") == true) //判定開頭是不是 F 開頭,主要是因為我的 Listbox2 裡面有其他資料
{
textBox7.Text = debug_sn.Substring(0, 5); //從 0 位址開始擷取,取 5 個字元
textBox8.Text = debug_sn.Substring(0, 10);
textBox9.Text = debug_sn.Substring(10, 5);
}


其他網站找到的。
(來源:http://www.dotblogs.com.tw/yc421206/archive/2008/11/03/5863.aspx )


String.Compare:比較兩個字串的值。傳回整數值。
String.CompareOrdinal:比較兩個字串,不管本地文化特性。傳回整數值。
String.CompareTo:將目前的字串物件與另一個字串加以比較。傳回整數值。
String.StartsWith:判斷字串的開頭是否為傳入的字串。傳回布林值。
String.EndsWith:判斷字串的結尾是否為傳入的字串。傳回布林值。
String.Equals:判斷兩個字串是否相同。傳回布林值。
String.IndexOf:從您正在檢查的字串開頭開始,傳回字元或字串的索引位置。傳回整數值。
String.LastIndexOf:從您正在檢查的字串結尾開始,傳回字元或字串的索引位置。傳回整數值。

字串處理範例:
http://msdn.microsoft.com/zh-tw/library/ms228364%28VS.80%29.aspx

常用C#字串處理函數
http://msdn.microsoft.com/zh-tw/library/system.string_methods%28VS.80%29.aspx

名稱 說明
Public method Supported by the .NET Compact Framework Clone 傳回對 String 這個執行個體的參考。
Public method Static Supported by the .NET Compact Framework Compare 多載。 比較兩個指定的 String 物件。
Public method Static CompareOrdinal 多載。 藉由評估每個字串中對應的 Char 物件之數字值,比較兩個 String 物件。
Public method CompareTo 多載。 將這個執行個體與指定的物件或 String 相比較,並傳回它們的相對值指示。
Public method Static Supported by the .NET Compact Framework Concat 多載。 串連一個或多個 String 的執行個體,或者一個或多個 Object 執行個體值的 String 表示。
Public method Contains 傳回值,指出指定的 String 物件是否會出現在這個字串內。
Public method Static Supported by the .NET Compact Framework Copy 使用與指定的 String 相同的值,建立 String 的新執行個體。
Public method Supported by the .NET Compact Framework CopyTo 將字元的指定數目從這個執行個體的指定位置,複製到 Unicode 字元陣列的指定位置。
Public method Supported by the .NET Compact Framework EndsWith 多載。 判斷 String 執行個體的結尾是否符合指定之字串。
Public method Supported by the .NET Compact Framework Equals 多載。 覆寫。 判斷兩個 String 物件是否具有相同的值。
Public method Static Supported by the .NET Compact Framework Format 多載。 以與對應物件值相等的文字,取代指定 String 中的每個格式項目。
Public method GetEnumerator 擷取可以逐一查看這個字串中個別字元的物件。
Public method Supported by the .NET Compact Framework GetHashCode 覆寫。 傳回這個字串的雜湊程式碼。
Public method Supported by the .NET Compact Framework GetType 取得目前執行個體的 Type。 (繼承自 Object)。
Public method Supported by the .NET Compact Framework GetTypeCode 傳回類別 String 的 TypeCode。
Public method Supported by the .NET Compact Framework IndexOf 多載。 報告這個字串中 String 或一或多個字元之第一個符合項目的索引。
Public method Supported by the .NET Compact Framework IndexOfAny 多載。 報告指定 Unicode 字元陣列中的任何字元於這個執行個體中第一個符合項目的索引。
Public method Supported by the .NET Compact Framework Insert 在這個執行個體的指定索引位置,插入 String 的指定執行個體。
Public method Static Supported by the .NET Compact Framework Intern 擷取指定的 String 的系統參考。
Public method Static Supported by the .NET Compact Framework IsInterned 擷取對指定 String 的參考。
Public method IsNormalized 多載。 指出這個字串是否為特定的 Unicode 正規化格式。
Public method Static Supported by the .NET Compact Framework IsNullOrEmpty 指出指定的 String 物件是否為 Null 參照 (即 Visual Basic 中的 Nothing) 或 Empty 字串。
Public method Static Supported by the .NET Compact Framework Join 多載。 將指定 String 陣列每個元素之間的指定分隔符號 String 串連,產生單一的串連字串。
Public method Supported by the .NET Compact Framework LastIndexOf 多載。 報告這個執行個體中指定 Unicode 字元或 String 最後項目的索引位置。
Public method Supported by the .NET Compact Framework LastIndexOfAny 多載。 報告 Unicode 陣列中的一個或多個指定字元在這個執行個體中最後項目的索引位置。
Public method Normalize 多載。 傳回新的字串,其二進位表示為特定的 Unicode 正規化格式。
Public method Static Supported by the .NET Compact Framework op_Equality 判斷兩個指定的 String 物件是否具有相同的值。
Public method Static Supported by the .NET Compact Framework op_Inequality 判斷兩個指定的 String 物件是否具有不同的值。
Public method Supported by the .NET Compact Framework PadLeft 多載。 將這個執行個體中的字元靠右對齊,以空格或指定的 Unicode 字元在左側填補至指定的總長度。
Public method Supported by the .NET Compact Framework PadRight 多載。 將這個字串中的字元靠左對齊,以空格或指定的 Unicode 字元在右側填補至指定的總長度。
Public method Static Supported by the .NET Compact Framework ReferenceEquals 判斷指定的 Object 執行個體是否為相同的執行個體。 (繼承自 Object)。
Public method Supported by the .NET Compact Framework Remove 多載。 從這個執行個體中刪除指定數目的字元。
Public method Supported by the .NET Compact Framework Replace 多載。 以另一個指定的 Unicode 字元或 String,取代這個執行個體中指定的 Unicode 字元或 String 的所有項目。
Public method Supported by the .NET Compact Framework Split 多載。 傳回 String 陣列,其中包含這個執行個體中由指定的 Char 或 String 陣列之元素所分隔的子字串。
Public method Supported by the .NET Compact Framework StartsWith 多載。 判斷 String 執行個體的開頭是否符合指定之字串。
Public method Supported by the .NET Compact Framework Substring 多載。 從這個執行個體擷取子字串。
Public method Supported by the .NET Compact Framework ToCharArray 多載。 將這個執行個體中的字元複製到 Unicode 字元陣列中。
Public method Supported by the .NET Compact Framework ToLower 多載。 傳回轉換成小寫的這個 String 複本。
Public method ToLowerInvariant 傳回轉換成小寫的這個 String 物件之複本,透過的方式是使用不因文化特性而異的大小寫規則。
Public method Supported by the .NET Compact Framework ToString 多載。 覆寫。 將這個執行個體的值轉換為 String。
Public method Supported by the .NET Compact Framework ToUpper 多載。 傳回轉換成大寫的這個 String 複本。
Public method Supported by the .NET Compact Framework ToUpperInvariant 傳回轉換成大寫的這個 String 物件之複本,透過的方式是使用不因文化特性而異的大小寫規則。
Public method Supported by the .NET Compact Framework Trim 多載。 將指定字元集的所有項目從這個執行個體的開頭和結尾移除。
Public method Supported by the .NET Compact Framework TrimEnd 將陣列中指定的字元集之所有項目從這個執行個體的結尾移除。
Public method Supported by the .NET Compact Framework TrimStart 將陣列中指定的字元集之所有項目從這個執行個體的開頭移除。



String.Substring( ):從指定的字元位置開始截取字串
語法:字串變數.Substring(左起始位數 , 取幾位)
範例:string s1 = str.Substring(0,2);

String.length():取得字串長度
String.Remove(int1,int2):從int1(起始位置)開始刪除長度為int2的字串
String.Insert(int,string):在int的位置插入string
String.Substring(int):從參數開始取出剩下的字串
String.Substring(int1,int2):取出int1開始長度為int2的字串
String.IndexOf(string):傳回第一次搜尋到字串(string)的位置
String.IndexOf(string,int):傳回第一次搜尋到字串(string)的位置,開始搜尋位置為int
String.LastIndexOf(string):跟IndexOf功能類似,但從後面開始搜尋
String.LastIndexOf(string,int):跟IndexOf功能類似,但從後面開始搜尋
String.Replace(char,char):取代字元
String.ToLower():將英文轉成小寫
String.ToUpper():將英文轉成大寫
String.Trim():刪除字串前後的空白字元
String.TrimEnd():刪除字串尾部的空白字元
String.TrimStart():刪除字串開頭的空白字元

2009年2月20日 星期五

公司內使用 3.5G 無線網卡連接外網的方法(未完)

由於 公司有自己的內部網路,通過公司網路 經由 Proxy 來收信、上網、開啟公司內區網資料夾
但是 公司有鎖一些對外的 Port ,所以很多壞事都不能做 -_-|||

在下有 3.5G 的無線網卡,想說可以一起使用 ,達到可以一邊收公司的信件來處理公事,
一方面又可以連上我喜歡的網站下載一些資源。

重點是如何來實現。

Test 1 :
將 3.5G 裝上,同時公司網路 也接上,發現 E-Mail 等都通過 3.5G 來處理,
查了一下原因,是因為 3.5G 速度快(Metric 比較低),Windows 在處理的時候
會自動優先選擇 Metric 比較低的網路,所以變成 公司網路完全無視!!

Test 2:
上網爬文發現,可以利用 Route 來做一些 指定的功能。

在MS DOS 下執行:
route print (可以檢視目前 的狀態)
route add 目標IP mask 子遮罩IP 希望走的網路Gateway

只是 測試了以後發現,還是不行阿。。。
只好先擺者,有空在研究了!!

未完

C# 鍵盤的按鍵判斷

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
//判斷 textbox1 裡面是不是 按Enter(Enter = 13) ,如果是 才動作
if (e.KeyChar == 13)
{
button1.Focus();

}

C# Try catch 例外處理!!超強~

再也不怕程式死當了!!



try
{
if (!string.IsNullOrEmpty(strValue))
{
File.WriteAllText(strFile, strValue, Encoding.UTF8);
MessageBox.Show("下載好了");
}
}
//直接把程式錯誤訊息 Show 出來
catch(Exception QQ)
{
MessageBox.Show(QQ.Message.ToString());
}
}