Kaneboy's Blog

SharePoint & Office Zealot
随笔 - 361, 评论 - 3663, 引用 - 201

导航

关于






Passed:
SPS2003 Infrastructure√
SPS2003 Custom Applications√
TS : WSS3.0 Configuration√
TS : WSS3.0 App Development√
TS : MOSS2007 Configuration√
TS : MOSS2007 App Development√
MCPD : Web Development√

此Blog中的文章和随笔只代表作者某一时间内的个人观点或结论,不代表任何公司立场和观点,也对其正确性没有任何担保或假设。(版权声明:作者原创文章和随笔的转载,请知会作者。)

点击这里查看此blog所有SharePoint文章!

SharePoint 2007 Starter Page

SharePoint External Binary Storage
QuickPart : 用户控件包装器 for SharePoint2007






标签

每月存档

最新留言

广告

 

这两天帮一个朋友调试使用BDC(Business Data Catalog)来连接MySql中的数据,发现不少需要特别注意的地方。在使用BDC连接时,MySql和MS Sql Server的区别还是很大的。

我的朋友在服务器上是使用的MyODBC这个Driver。对于LobSystemInstance的定义,基本类似:

<LobSystemInstance Name="MySQL_Lob">
      <Properties>
        <Property Name="rdbconnection Driver" Type="System.String">{MySQL ODBC 3.51 Driver}</Property>
        <Property Name="rdbconnection server" Type="System.String">MySQL服务器名称</Property>
        <Property Name="rdbconnection database" Type="System.String">MySQL Database名称</Property>
        <Property Name="rdbconnection user" Type="System.String">root</Property>
        <Property Name="rdbconnection password" Type="System.String">123456</Property>
        <Property Name="rdbconnection option" Type="System.String">3</Property>
        <Property Name="RdbConnection Trusted_Connection" Type="System.String">true</Property>
        <Property Name="DatabaseAccessProvider" Type="Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAccessProvider">Odbc</Property>
        <Property Name="AuthenticationMode" Type="Microsoft.Office.Server.ApplicationRegistry.SystemSpecific.Db.DbAuthenticationMode">PassThrough</Property>
      </Properties>
</LobSystemInstance>


不同的Database Driver,其Connection String是不同的。所以如果你使用的并非MyODBC Driver,那么LobSystemInstance的写法会有不同。

由于我对MySQL并不熟悉,所以在写Entity的Method的时候,又遇到不少问题。其中之一是SQL语句的Parameter的问题。对于MS SqlServer,我们可以使用类似“@ParameterName”的格式来定义SQL语句中的参数。但是,这对于MySQL并不一定有效。使用不同的Database Driver去连接MySQL,对于参数,都有不同的定义方法。我搜索了一下MyODBC的文档,发现它不支持命名参数,而直接使用“?”来代表参数,然后按照顺序来添加参数的值。

所以,在写Entity Method的SQL查询语句时,如果其中有参数,就只能写成类似:

Select CustomerID, CustomerName, ContactName from Customers where CustomerID = ?

但是Entity中Parameter的定义,仍然可以按与命名参数一模一样的写法即可。

打印 | 张贴于 2008-02-24 12:10:01 | Tag:SharePoint

留言反馈

暂时没有留言纪录

发表留言

标题
姓名
邮件
主页
留言 

Powered by: Joycode.MVC引擎 0.5.1.8