zoukankan      html  css  js  c++  java
  • 使用BDC连接MySql可能遇到的问题

    这两天帮一个朋友调试使用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的定义,仍然可以按与命名参数一模一样的写法即可。

  • 相关阅读:
    Cycling Label
    设置Eclipse的类文件和xml文件代码自动补全
    搭建maven环境
    Android依赖管理与私服搭建
    Cname与A记录(Address)区别
    mysql5.6.34在默认配置文件修改字符集为utf8后重启mysql服务没效果
    PHP将HTML的内容保存成word文档
    常用 Git 命令清单
    广告中的AdNetwork、AdExchange、DSP、SSP、RTB和DMP是什么?
    PHP两个日期之间的所有日期
  • 原文地址:https://www.cnblogs.com/kaneboy/p/2436981.html
Copyright © 2011-2022 走看看