C#Àï¹ØÓÚ¶¨Ê±Æ÷Àà
¹ØÓÚC#ÖÐtimerÀà ÔÚC#Àï¹ØÓÚ¶¨Ê±Æ÷Àà¾ÍÓÐ3¸ö
1.¶¨ÒåÔÚSystem.Windows.FormsÀï
2.¶¨ÒåÔÚSystem.Threading.TimerÀàÀï
3.¶¨ÒåÔÚSystem.Timers.TimerÀàÀï
System.Windows.Forms.TimerÊÇÓ¦ÓÃÓÚWinFormÖеģ¬ËüÊÇͨ¹ýWindowsÏûÏ¢»úÖÆÊµÏֵģ¬ÀàËÆÓÚVB»òDelphiÖеÄTimer¿Ø¼þ£¬ÄÚ²¿Ê¹ÓÃAPI SetTimerʵÏֵġ£ËüµÄÖ÷ҪȱµãÊǼÆÊ±²»¾«È·£¬¶øÇÒ±ØÐëÓÐÏûϢѻ·£¬Console Application(¿ØÖÆÌ¨Ó¦ÓóÌÐò)ÎÞ·¨Ê¹Óá£
System.Timers.TimerºÍSystem.Threading.Timer·Ç³£ÀàËÆ£¬ËüÃÇÊÇͨ¹ý.NET Thread PoolʵÏֵģ¬ÇáÁ¿£¬¼ÆÊ±¾«È·£¬¶ÔÓ¦ÓóÌÐò¡¢ÏûϢûÓÐÌØ±ðµÄÒªÇó¡£System.Timers.Timer»¹¿ÉÒÔÓ¦ÓÃÓÚWinForm£¬Íêȫȡ´úÉÏÃæµÄTimer¿Ø¼þ¡£ËüÃǵÄȱµãÊDz»Ö§³ÖÖ±½ÓµÄÍÏ·Å£¬ÐèÒªÊÖ¹¤±àÂë¡£
Àý£º
ʹÓÃSystem.Timers.TimerÀà
System.Timers.Timer t = new System.Timers.Timer(10000);//ʵÀý»¯TimerÀ࣬ÉèÖüä¸ôʱ¼äΪ10000ºÁÃ룻
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//µ½´ïʱ¼äµÄʱºòÖ´ÐÐʼþ£»
t.AutoReset = true;//ÉèÖÃÊÇÖ´ÐÐÒ»´Î£¨false£©»¹ÊÇÒ»Ö±Ö´ÐÐ(true)£»
t.Enabled = true;//ÊÇ·ñÖ´ÐÐSystem.Timers.Timer.Elapsedʼþ£»
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("OK!");
}
Ïà¹ØÎĵµ£º
½ñÌìÔÚÍøÉÏÕÒÁËÐí¾Ã¹ØÓÚsqlserverÖд洢imageÀàÐͺͶÁÈ¡imageµÄ·½·¨£¬¿ÉÊǶ¼ÊÇÄÇôһµã£¬¹ÊÔÚ´ËÂÞÁÐһϣ¬Ï£Íû¿ÉÒÔ°ïÖú´ó¼Ò¡£
Ê×ÏÈÊǹØÓÚdataGridViewµÄ°ó¶¨¡£´úÂë¼ûÏÂ
private void button_show_Click(object sender, EventArgs e)
{
string sqlText = "server=localhost;initial catalog=Test; ......
C#Á¬½ÓMySQLÊý¾Ý¿â·½·¨
1¡¢ÓÃMySQLDriverCSÁ¬½ÓMySQLÊý¾Ý¿âÏÈÏÂÔØºÍ°²×°MySQLDriverCS£¬µØÖ·£º
http://sourceforge.net/projects/mysqldrivercs
ÔÚ°²×°Îļþ¼ÐÏÂÃæÕÒµ½MySQLDriver.dll£¬È»ºó½«MySQLDriver.dllÌí¼ÓÒýÓõ½ÏîÄ¿ÖÐ
×¢£ºÎÒÏÂÔØµÄÊǰ汾ÊÇ MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe
using System; ......
µ±ÔÚC#ÓïÑÔÖУ¬Á¬½ÓsqlÊý¾Ý¿âµÄʱºò£¬³£Óõ½sqlconnection½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó¡£ Óï·¨ÈçÏ£º
String sqlcon = "***";//ÕâÀïÊÇÒ»¸ö×Ö·û´®£¬¾ßÌå¸úÊý¾Ý¿âµÄÑéÖ¤·½Ê½Óйء£
//sql server Éí·ÝÑéÖ¤ Á¬½Ó×Ö·û´®
private string ConnstrSqlServer = "server=·þÎñÆ÷Ãû³ ......