原创 c#找出字符串中出現最多的字符及次數

        private static void GetMostChar()         {             string str = "aaabbbccceeefff111144444";             Di

原创 C# 1,2,3,4四個數字組成無重複數字的三位數

        private static List<int> CombineNum()         {             List<int> list = new List<int>() { 1, 2, 3, 4 };  

原创 C#分解質因數

        private static string ResolveNum(int a)         {             if (ReturnNum(a) == 0)                 return a.T

原创 C# WinForm 判斷程序是否已經在運行,且只允許運行一個實例

static class Program{  /// <summary>  /// 應用程序的主入口點。  /// </summary>  [STAThread]  static void Main()  {    Application

原创 報錯:1130-host ... is not allowed to connect to this MySql server 開放mysql遠程連接 不使用localhost

報錯:1130-host ... is not allowed to connect to this MySql server解決方法:1。 改表法。可能是你的帳號不允許從遠程登陸,只能在localhost。這個時候只要在localhos

原创 C#將1970年以來的日期轉換成秒數以及反轉

// 不能用DateTime.Now,否則會有8h時差  int seconds = Convert.ToInt32(DateTime.UtcNow.Subtract(DateTime.Parse("1970-1-1")).TotalSe

原创 查詢一張表中某兩個字段相同的數據

select * from table1 t where (select count(1) from table1 where b=t.b and d=t.d)>1

原创 DEV gridcontrol雙擊行事件

        private void gridView1_MouseDown(object sender, MouseEventArgs e)        {            try            {         

原创 sql top和distinct合用

關於sql中的distinct和top合用如果想要在去重後選出的數據中選出前三條,則應該將distinct寫在top的前面,例如SELECT DISTINCT TOP 3 USERNAME,PASSWORD FROM USERS WHER

原创 批處理

批處理刪除文件夾下所有文件和文件夾1、rd命令rd /s /Q c:\temp會將temp文件夾也刪除2、rd命令+md命令rd /s /Q c:\tempmd c:\Temp刪除後再重建3、del命令del /s /Q c:\temp只

原创 DEV GridControl控件設置單元格換行

foreach (DataRow row in dataTable.Rows) {        row["columnName"] = ((String)row["columnName"]).Replace(@"\n", Environ

原创 SQL語句實現兩張表之間不存在則插入,存在則更新

if not exists (select columnname1,columnname2 from tablename1) insert into tablename1 (columnname1,columnname2.....) se

原创 C#寫日誌文件

//日誌寫法 public void WriteLog(string msg)   {       string filePath = AppDomain.CurrentDomain.BaseDirect