2008年1月9日 星期三

將ANSI編碼的文字轉為Unicode

source 來源:啟隆
Response.Write(Util.Big52Unicode(tt));
///
/// ANSI轉Unicode
///

///
///
public static string Big52Unicode(string str)
{
new Regex("&#(?[^;]+)", RegexOptions.IgnoreCase);
Match mc = re.Match(str);
while (mc.Success)
{
int S = Convert.ToInt32(mc.Result("${pp}"));
string newS = Char.ConvertFromUtf32(S);
//HttpContext.Current.Response.Write(Char.ConvertFromUtf32(S) +
"
");
str = str.Replace("&#" + S + ";", newS);
mc = mc.NextMatch();
}

return str;
}

完整備份SQLServer

http://www.sqldbatips.com/showarticle.asp?ID=37

using Microsoft.SqlServer.Management.Smo;

namespace SMOTest
{
class Program
{
static void Main()
{
Server svr = new Server();
Backup bkp = new Backup();
bkp.Devices.AddDevice(@"C:\SMOTest.bak", DeviceType.File);
bkp.Database = "SMO";
bkp.Action = BackupActionType.Database;
bkp.Initialize = true;
bkp.PercentCompleteNotification = 10;
bkp.PercentComplete += new PercentCompleteEventHandler(bkp_PercentComplete);
bkp.SqlBackup(svr);
}

static void bkp_PercentComplete(object sender, PercentCompleteEventArgs e)
{
Console.WriteLine(e.Percent.ToString() + "% backed up");
}
}
}