Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 Ò»´ÎÖ´ÐжàÌõÓï¾äµÄʵÏÖ¼°³£¼ûÎÊÌâ

´úÂëÈçÏÂ:
//Á´½ÓʱÉ趨
mysql_real_connect( ..., CLIENT_MULTI_STATEMENTS );
//»òÕß
//ÖÐ;ָ¶¨
mysql_set_server_option( mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON ); //mysqlÊÇÁ¬½ÓµÄÃû³Æ
µ±Ê¹ÓÃÖ´ÐжàÓï¾ä¹¦Äܺó£¬Ò»¶¨Òª¶ÁÍêÕû¸öresault¼¯£¬·ñÔò»á³öÏÖ´íÎó£ºCommands out of sync; you can't run this co ......

Java °ÑÎı¾ÖеÄÊý¾Ý²åÈëµ½MySqlÊý¾Ý¿â

Ò»¹²ÓÐÈý¸öÀࣺWriteFile ; ReadFile ; InsertDB ;
//WriteFile.java
//ÓÃÓÚ½«ÐÅϢдÈëÎı¾Îļþ
package org.mb.insertfromfile;
import java.io.*;
public class WriteFile{
private int count = 0 ;
public int getCount() {
return count;
}
public void setCount(int count) {
this.cou ......

mysql alter Óï¾äÓ÷¨,Ìí¼Ó¡¢Ð޸ġ¢É¾³ý×ֶεÈ


//Ö÷¼ü
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//Ôö¼ÓÒ»¸öÐÂÁÐ
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//ɾ³ýÁÐ
alter table t2 drop column c;
//ÖØÃüÃûÁÐ
......

¾­µäµÄMYSQLÓï¾ä

·Ç³£³£Óõģº¾­µäµÄMYSQLÓï¾ä…… php¿ªÔ´
ÕâÕæÊÇÒ»¸öºÃ¶«Î÷£ºÑ§Ï°ºÃÁ˺ÜÊÜÓõÄŶ……
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(Create£¬Alter£¬Drop£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(Select£¬Delete£¬Update£¬Insert)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)php¿ªÔ´
Ê×ÏÈ,¼òÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ