C# ODBC·ÃÎÊMySQLÊý¾Ý¿â
·Ï»°²»ËµÁË£¬Ö±½Ó½øÈëÖ÷Ì⣬C# ODBC·ÃÎÊMySQLÊý¾Ý¿â£º
1.°²×°Microsoft ODBC.net£ºÎÒ°²×°µÄÊÇmysql-connector-odbc-3.51.22-win32.msi
2.°²×°MDAC 2.7»òÕ߸ü¸ß°æ±¾£ºÎÒ°²×°µÄÊÇmdac_typ.exe 2.7¼òÌåÖÐÎİæ
3.°²×°MySQLµÄODBCÇý¶¯³ÌÐò£ºÎÒ°²×°µÄÊÇ odbc_net.msi
4.¹ÜÀí¹¤¾ß -> Êý¾ÝÔ´ODBC –>ÅäÖÃDSN…
5.½â¾ö·½°¸¹ÜÀíÖÐÌí¼ÓÒýÓà Microsoft.Data.Odbc.dll(1.0.3300)
6.C# ODBC·ÃÎÊMySQLÊý¾Ý¿â´úÂëÖÐÔö¼ÓÒýÓà using Microsoft.Data.Odbc;
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Drawing;
usingSystem.Linq;//vs2005ºÃÏñûÓÐÕâ¸öÃüÃû¿Õ¼ä£¬ÔÚc#2008ϲâÊÔ×Ô¶¯Éú³ÉµÄ
usingSystem.Text;
usingSystem.Windows.Forms;
usingMicrosoft.Data.Odbc;
namespacemysql{
publicpartialclassForm1:Form{
publicForm1(){
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse){
stringMyConString
=
"DRIVER={MySQLODBC3.51Driver};"
+
"
SERVER
=
localhost
;"+
"
DATABASE
=
inv
;"+
"
UID
=
root
;"+
"
PASSWORD
=
831025
;"+
"
OPTION
=
3
";
OdbcConnectionMyConnection
=
newOdbcConnection
(MyConString);
MyConnection.Open();
Console.WriteLine("\nsuccess,connectedsuccessfully!\n");
stringquery
=
"insertintotestvalues('hello','lucas','liu')"
;
OdbcCommandcmd
=
newOdbcCommand
(query,MyConnection);
//´¦ÀíÒì³££º²åÈëÖØ¸´¼Ç¼ÓÐÒì³£
try{
cmd.ExecuteNonQuery();
}
catch(Exceptionex){
Console.WriteLine("recordduplicate.");
}
finally{
cmd.Dispose();
}
stringtmp1
=
null
;
stringtmp2
=
null
;
stringtmp3
=
null
;
query
=
"select*fromtest"
;
OdbcCommandcmd2
=
newOdbcCommand
(query,MyConnection);
OdbcDataReaderreader
=
cmd
Ïà¹ØÎĵµ£º
<p>04¼¶ÐÂÉúÃûµ¥</p>
<table border="1" width="80%" cellpadding="0">
<tr>
<td width="10%" align="center">Id</td>
<td width="20%" align="center">Name</td>
<td width="10%" align="center">Age</td>
<td width="10%" align="cent ......
Ò»¡¢IPÐÅÏ¢ÁÐ±í£º
Ãû³Æ IP
LVS-DR-VIP 192.168.50.245
LVS-DR-Master ......
1.½¨±íʱ¾Í´´½¨×ÔÔöÁУº
create table test
(
id int auto_increment primary key,
name varchar(20) not null,
password varchar(20) not null
);
insert into test values(null,'aa','aa');
insert into test values(null,'bb','bb');
×¢Ò⣺
²åÈëÓï¾äʱ£¬×Ô ......
ÁªºÏMySQL Proxy ºÍMySQL Cluster£¬¹¹½¨¸ßÐÔÄÜÊý¾Ý¿â
ÔÎÄ£ºhttp://blogs.mysql.com/kaj/2007/12/10/combining-mysql-proxy-with-mysql-cluster/
²»¾Ãǰ£¬ÎÒºÍStewart Smith, Vinay Joosery, Monty Taylor ÒÔ¼°ÆäËûµÄmysqlʹÓÃÕߣ¨ËûÃDZÈÎÒ¸üÊìϤMySQL Cluster £©Õ¹¿ªÁËÒ»´ÎÌÖÂÛ£ ......