用Oracle 使用TransactionScope錯誤訊息
2016年5月5日 星期四
在使用TransactionScope,要特別注意是否有安裝以下元件,不然會有以下錯誤訊息:
Exception type: System.InvalidOperationException
Message: The Promote method returned an invalid value for the distributed transaction.
需要檢查
在使用TransactionScope,要特別注意是否有安裝以下元件,不然會有以下錯誤訊息:
Exception type: System.InvalidOperationException
Message: The Promote method returned an invalid value for the distributed transaction.
需要檢查
今天遇到一個特別的情況,所以筆記一下
用Javascript的.getYear(),取出得到的是115
原來因為2000年的問題,getYear()只會回傳二位數,所以現在早就不能用了,要改用getFullYear()
參考來源:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getYear
Read more...
using System;
public class GetNameTest {
enum Colors { Red, Green, Blue, Yellow };
enum Styles { Plaid, Striped, Tartan, Corduroy };
public static void Main() {
Console.WriteLine("The 4th value of the Colors Enum is {0}", Enum.GetName(typeof(Colors), 3));
Console.WriteLine("The 4th value of the Styles Enum is {0}", Enum.GetName(typeof(Styles), 3));
}
}
public static class HelpExtensions
{
public static string GetEnumDescription(this Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
//若取不到屬性,則取名稱
if ((attributes != null) && (attributes.Length > 0))
return attributes[0].Description;
else
return value.ToString();
}
}
public enum MessageType
{
[Description("Create")]
Creation = 1,
[Description("Update")]
Updating = 2,
[Description("Del")]
Deletion = 3,
[Description("Select")]
Selection = 4
}
//使用方式
var messageType = MessageType.Deletion.GetEnumDescription();
Console.WriteLine("Ouput:" + messageType);
//顯示結果
//Output:Del
Read more...
查詢指令
csc /help
編譯cs檔方式
C:\Windows\Microsoft.NET\Framework\v4.0.30319>csc /t:exe /out:c:\helloworld\hell
oworld.exe c:\helloworld\helloworld.cs
public class HelloWorld
{
public static void Main(string[] args)
{
System.Console.WriteLine("Hello World!");
System.Console.ReadLine();
}
}
今天遇到使用Guid.NewGuid在IE8的奇怪問題
如果在網站列按Enter則會發生,但按F5重新整理確不會
最後確定是瀏覽器Cache問題造成的,我來重現一下實際的情況
測試程式如下:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Guid.NewGuid().ToString() );
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetNoStore(); //清除Cache
Response.Write(Guid.NewGuid().ToString() );
}
Read more...