一提起mysql数据库,好像就是在说java,jsp或者php,其实在所有程序中都可以使用mysql 数据库,其它的程序使用my sql数据库的方法是使用my sql 提供的odbc驱动,在.net 中可以使用类似于jdbc似的东东.它的名字是:MySQLDriverCS.dll.把它添加到.net的组件面板里,至于如何添加,则不是本篇的任务了(^_^)!
下面是创建一个数据库链接:
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
如果你使用的是.net的集成开发环境(visual studio.net)那么在代码中输入MySQLDriverCS后再输入一个”.”就可以看到MySQLDriverCS名称空间中的所有的东西了.
下面是commond:
1
MySQLCommand cmd;
2
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
3
cmd.ExecuteNonQuery();
4
cmd.Dispose();
5![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
6![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
7
cmd = new MySQLDriverCS.MySQLCommand("CREATE TABLE test.mysqldrivercs_test("+
8
"SettingID tinyint(3) unsigned NOT NULL auto_increment,"+
9
"SettingValue text, "+
10
"PRIMARY KEY (SettingID), UNIQUE KEY SettingID(SettingID), KEY SettingID_2 (SettingID))"+
11
" TYPE=MyISAM COMMENT='MySQL test table'",conn);
12
13
cmd.ExecuteNonQuery();
14
cmd.Dispose();
15![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
下面是insert:
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://dagco.cnblogs.com/Images/OutliningIndicators/None.gif)
文章来源:http://blog.csdn.net/vstart/archive/2006/06/09/783510.aspx