Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C#Á¬½ÓMySQL½øÐвÙ×÷µÄ·½·¨

ÓÉÓÚÐèҪʵÏÖÒÔϹ¦ÄÜ£º
Íø¹ØÍ¨¹ý´®¿Ú·¢ËÍÊý¾Ý¸øPC»ú£¬PC»úÊÕ¼¯Êý¾Ý²¢½âÎö±£´æµ½MySQLÖУ¬È»ºóJSPÒ³Ãæ¶ÁÈ¡MySQLÖеÄÊý¾Ý²¢ÏÔʾ¡£
ËùÒÔÀûÓÃC#Á¬½ÓMySQLÊý¾Ý³ÉΪÁ˱ØÐëÒª¾­¹ýµÄ¹ý³Ì£¬Ôڴ˸øÓèÏêϸµÄ˵Ã÷¡£
1¡¢ÏÂÔØÐèÒªµÄÎļþMySQLDriverCS£¬ÏÂÔØµØÖ·Îª£ºhttp://sourceforge.net/projects/mysqldrivercs
2¡¢°²×°Îļþ£ºMySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe£¬ÔÚ°²×°¹ý³ÌÖÐÒ²Ðí»áÌáʾһ¸ö´íÎ󣬽ûֹдһ¸ödllÎļþ£¬ÄãÖ±½ÓºöÂԾͿÉÒÔÁË¡£
3¡¢½«°²×°ÎļþϵÄMySQLDriver.dllÎļþÌí¼Óµ½C#ÏîÄ¿µÄÒýÓÃÖС£
4¡¢È»ºóд¹«¹²´¦ÀíÀàÈçÏ£º
(1) Ê×ÏȵÃÒýÓÃÃüÃû¿Õ¼ä£º
using MySQLDriverCS;
using System.Data;
using System.Data.Odbc;
(2) д¹«¹²´¦ÀíÀà
public class SQLHelper
{
MySQLConnection conn = null;
MySQLCommand commn = null;

public MySQLConnection GetConnect()
{
conn = new MySQLConnection(new MySQLConnectionString("localhost", "wwater", "root", "123").AsString);
return conn;
}
public int RunMySQL(string sql)
{
int count = 0;
try
{
conn = GetConnect();
conn.Open();
commn = new MySQLCommand(sql, conn);
count = commn.ExecuteNonQuery();
return count;
}
catch (Exception ex)
{
throw;
}
finally
{
conn.Close();
}
}
}
(3) ÔÚʵ¼Ê¹ý³ÌÖнøÐÐÒýÓÃRunMySQL·½·¨¼´¿É²åÈëÊý¾ÝÁË¡£  


Ïà¹ØÎĵµ£º

mysql Ë÷Òý

1
Ë÷ÒýµÄÒâÒ壺
Óŵ㣺
Ë÷ÒýÓÃÀ´¿ìËÙµØÑ°ÕÒÄÇЩ¾ßÓÐÌØ¶¨ÖµµÄ¼Ç¼£¬Èç¹ûûÓÐË÷Òý£¬Ö´Ðвéѯʱ±ØÐë´ÓµÚÒ»¸ö¼Ç¼¿ªÊ¼É¨Ãè±íÖÐËùÓмǼ£¬±íÀïÃæµÄ¼Ç¼ÊýÁ¿Ô½¶à£¬Õâ¸ö²Ù×÷µÄ´ú¼Û¾ÍÔ½¸ß¡£
    
ȱµã£º
Ë÷ÒýÒªÕ¼ÓôÅÅ̿ռ䣻ÇÒÈκÎд²Ù×÷Éæ¼°µÄË÷Òý¸öÊý¶àµÄ»°»áÒýÆð½µËÙ£¬ÒòΪ
MySQL
²»½öÒª°Ñ¸Ä¶¯Êý¾ ......

½«Í¼Æ¬µÈÎļþ±£´æµ½sqliteÖУ¨c#£©

 SqLite.netµÄdllΪSystem.Data.SQLite.dll£¬ÕâÖÖdll·ÖΪ32λ¡¢64λºÍÊÊÓÃÓÚcompactframeworkÈýÖÖ£¬ÔÚÒýÓÃʱҪעÒ⣬ѡÔñÕýÈ·µÄdll¡£
½«Òª±£´æÍ¼Æ¬µÄ×Ö¶ÎÀàÐÍÉèΪblob¡£´úÂëÈçÏ£º
private void savePicture£¨£©
{
using (SQLiteConnection cnn = new SQLiteConnection(dbPath))
......

linux mysqlÅäÖÃ


Ð¶ÔØmysql
1¡¢²éÕÒÒÔǰÊÇ·ñ×°ÓÐmysql
ÃüÁrpm -qa|grep -i mysql
¿ÉÒÔ¿´µ½mysqlµÄÁ½¸ö°ü£º
mysql-4.1.12-3.RHEL4.1
mysqlclient10-3.23.58-4.RHEL4.1
2¡¢É¾³ýmysql
ɾ³ýÃüÁrpm -e --nodeps °üÃû
( rpm -ev mysql-4.1.12-3.RHEL4.1 )
3¡¢É¾³ýÀϰ汾mysqlµÄ¿ª·¢Í·ÎļþºÍ¿â
ÃüÁrm -fr /usr/lib/mysql
r ......

MySQLÓëÊÂÎñ


MySQL5.X¶¼ÒѾ­·¢²¼ºÃ¾ÃÁË£¬µ«ÊÇ»¹ÓкܶàÈËÈÏΪMySQLÊDz»Ö§³ÖÊÂÎñ´¦ÀíµÄ£¬Õâ²»µÃ²»¹ÖËûÃÇÊǹª¹ÑÎŵ쬯äʵ£¬Ö»ÒªÄãµÄMySQL°æ±¾
Ö§³ÖBDB»òInnoDB±íÀàÐÍ£¬ÄÇôÄãµÄMySQL¾Í¾ßÓÐÊÂÎñ´¦ÀíµÄÄÜÁ¦¡£ÕâÀïÃæ£¬ÓÖÒÔInnoDB±íÀàÐÍÓõÄ×î¶à£¬ËäÈ»ºóÀ´·¢ÉúÁËÖîÈçOracleÊÕ
¹ºInnoDBµÈÁîMySQL²»Ë¬µÄÊÂÇ飬µ«ÄÇЩÉÌÒµÉϵĶ·ÕùÓë¼¼ÊõÎÞ¹ ......

MySQLµÄdatetimeÉèÖõ±Ç°Ê±¼äΪĬÈÏÖµ


MySQLµÄdatetimeÉèÖõ±Ç°Ê±¼äΪĬÈÏÖµ 
ÓÉÓÚMySQLĿǰ×ֶεÄĬÈÏÖµ²»Ö§³Öº¯Êý£¬ËùÒÔÓÃ
create_time datetime default now()
µÄÐÎʽÉèÖÃĬÈÏÖµÊDz»¿ÉÄܵġ£
´úÌæµÄ·½°¸ÊÇʹÓÃTIMESTAMPÀàÐÍ´úÌæDATETIMEÀàÐÍ¡£
CURRENT_TIMESTAMP £ºµ±ÎÒ¸üÐÂÕâÌõ¼Ç¼µÄʱºò£¬ÕâÌõ¼Ç¼µÄÕâ¸ö×ֶβ»»á¸Ä±ä
¡£
CURRENT_TIMESTAMP O ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ