.NET的数据库天然支持MSSQLServer,但是并非其他数据库不支持,而是微软基于自身利益需要,在支持、营销上推自己的数据库产品;但是作为平台战略,他并非排斥其他数据库,而是参考java体系提出了一套数据库访问规范,让各个第三方进行开发,提供特定的驱动。
http://www.microsoft.com/china/community/Columns/Luyan/6.mspx
而实际上,针对ODBC。Net的需要配置DSN的麻烦,而是出现了一个开源的系统MySQLDriverCS,对MySQL的开发进行了封装,实现了.net环境下对于MySQL数据库系统的访问。
http://sourceforge.net/projects/mysqldrivercs/
通过阅读源代码,我们看到MySQLDriverCS的思路是利用C函数的底层库来操纵数据库的,通常提供对MySQL数据库的访问的数据库的C DLL是名为libmySQL.dll的驱动文件,MySQLDriverCS作为一个.net库进行封装C风格的驱动。
具体如何进行呢?
打开工程后,我们看到其中有一个比较特殊的.cs文件CPrototypes.cs:
以下是引用片段:
| #region LICENSE /* MySQLDriverCS: An C# driver for MySQL. Copyright (c) 2002 Manuel Lucas Vi馻s Livschitz. This file is part of MySQLDriverCS. MySQLDriverCS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. MySQLDriverCS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with MySQLDriverCS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
| #endregion using System; using System.Data; using System.Runtime.InteropServices; namespace MySQLDriverCS { //[StructLayout(LayoutKind.Sequential)] public class MYSQL_FIELD_FACTORY { static string version; public static IMYSQL_FIELD GetInstance() { if (version==null) { version = CPrototypes.GetClientInfo(); } if (version.CompareTo("4.1.2-alpha")>=0) { return new MYSQL_FIELD_VERSION_5(); } else return new MYSQL_FIELD_VERSION_3(); } } public interface IMYSQL_FIELD { string Name{get;} uint Type{get;} long Max_Length {get;} } |
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- WPF的Attached属性 (0次浏览)
- WPF,将颠覆的设计世界? (0次浏览)
- Windows是否已经变成了一个怪物? (0次浏览)
- Windows2008用RODC保证分支机构安全 (0次浏览)
- Windows2008的NLB配置攻略 (0次浏览)
- Windows SharePoint Services 和 SharePoint P (0次浏览)
- Windows Forms中实现统一的数据验证(一) (0次浏览)
- Windows API一日一练:DrawText函数 (0次浏览)
- Win2008初次体验的几个心得 (0次浏览)
- WEB应用数据库访问的优化 (0次浏览)



