문제

How would I go about connecting to oracle from F#? Is there a drive or can I load up the C# driver? I'm very new to F#.

도움이 되었습니까?

해결책

You can use the same libraries as you use in C# - .NET interoperability is one of the key features of F#. There are some classes in the Base Class Library which you could use (in System.Data.Oracle.dll), but these have been deprecated in favor of Oracle's own .NET drivers (Oracle Data Provider for .NET).

F# code using ODP.NET might look something like:

#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)]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top