How to use MySql via Linq to SQL
The vs2008 and vs2010 don't support the generation LINQ to SQL business objects from a MySQL database, if you drop a MySql table to a Linq to Sql Class, it will popup a "The selected object(s) use an unsupported data provider" error.
Generation tool DBLinq
DbLinq is a LINQ to SQL data context provider and allows you to create LINQ to SQL business objects from a MySQL database and perform LINQ queries directly against MySQL tables. Utilizing LINQ, it functions in the same way as a typical SQL Server data layer.
a) Download DBLinq from: http://code.google.com/p/dblinq2007/downloads/list
b) Run the LINQ to SQL generation tool DbMetal.exe as follows:
DbMetal.exe -provider=MySql -database:MyDatebase -server:you host computer -user:mysql user -password:you pwd -namespace:mysqllinq -code:mysqllinq.cs -sprocs
Modify the generated file
The generated file can't be use in project right now, we must take some modification on it.
a) Delect all code with #if !MONO_STRICT(take MONO_STRICT as True is ok).
b) Delete the constructors from the DataContext class and add the following constructor:
public MyDBDataContext()
: base(new MySqlConnection(ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString))
{
OnCreated();
}
c) For "Incorrect AutoSync specification for member" error, we should set AutoSync of pk field as AutoSync.OnInsert, the full configuration for pk field:
[Column(Storage = "_userID", Name = "userId", DbType = "int", IsPrimaryKey = true, AutoSync = AutoSync.OnInsert, CanBeNull = false)]
As the .NET compiler will convert the code into a SQL Server syntax statement, run this code under MySql will throw error(Like this issue:http://lists.mysql.com/mysql/215385
相关文档:
在MySQL中,对于索引的使用并是一直都采用正确的决定。
简单表的示例:
create TABLE `r2` (
ID` int(11) DEFAULT NULL,
ID1` int(11) DEFAULT NULL,
CNAME` varchar(32) DEFAULT NULL,
KEY `ID1` (`ID1`)
) ENGINE=MyISAM DEFAULT charSET=latin1
select count(*) from r2;
......
导出.sql文件
1.将数据库transfer_server_db导出到transfSRV.sql文件中:
mysqldump -u root -p transfer_server_db > /home/eric/transfSRV.sql
2.将数据库transfer_server_db中的device_info_table导出到table.sql文件中:
mysqldump -u root -p transfer_server_db device_info_table > /home/eric/ta ......
Java连接mysql数据库,代码经过运行准确无误。
下面为实例---->
用数据库操纵工具(例:SQLyogEnt)操纵mysql建表,或dos下建,如下:
数据库名:scutcs
表名:student
表内容:
sno char[7] NO NULL Primary Key;
sname varchar[8] NO NULL;
sex char[2] NO NULL; ......
近来对php比较感兴趣,就断断续续的花了两个星期的时间把整个php开发需要用到的东西都装好了,大概的安装过程如下。
一、安装的软件:
Apache: 2.2.14
PHP:5.2.12
MySQL:5.1.42。
SVN:1.5.6
PHPMyAdmin:3.2.5
Zend Studio: 7.1
Zend Debugger: 5.1.14
二、安装过程:
1. 安装和配置apache
安装:首先从http://apa ......