【问题标题】:Connecting to Oracle from F#从 F# 连接到 Oracle
【发布时间】:2011-03-29 17:48:40
【问题描述】:

我将如何从 F# 连接到 oracle?是否有驱动器或者我可以加载 C# 驱动程序?我对 F# 很陌生。

【问题讨论】:

    标签: f# functional-programming c#-to-f#


    【解决方案1】:

    您可以使用在 C# 中使用的相同库 - .NET 互操作性是 F# 的关键特性之一。您可以使用基类库中的一些类(在 System.Data.Oracle.dll 中),但这些已被弃用,取而代之的是 Oracle 自己的 .NET 驱动程序(Oracle Data Provider for .NET)。

    使用 ODP.NET 的 F# 代码可能类似于:

    #if INTERACTIVE
      #r "System.Data"
      #r "Oracle.DataAccess"
    #endif
    
    open System.Data
    open Oracle.DataAccess.Client
    
    let conn = OracleConnection("User Id=scott;Password=tiger;Data Source=oracle")
    conn.Open()
    
    let cmd = conn.CreateCommand()
    cmd.CommandText = "select * from emp"
    
    let rdr = reader = cmd.ExecuteReader()
    
    let empIds = 
      [while reader.Read() do
         yield reader.GetInt32(0)]
    

    【讨论】:

      猜你喜欢
      • 2015-10-16
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 2019-12-26
      • 1970-01-01
      • 2019-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多