SQLProvider


ODBC

Configuring DSN on Windows ODBC Data Source Administrator server: Control Panel -> Administrative Tools -> Data Sources (ODBC) (or launch: c:\windows\syswow64\odbcad32.exe) and add your driver to DSN.

1: 
2: 
3: 
4: 
5: 
open FSharp.Data.Sql 
[<Literal>] 
let dnsConn = @"DSN=foo" 
type db = SqlDataProvider<Common.DatabaseProviderTypes.ODBC, dnsConn>
let ctx = db.GetDataContext()

Because there are a lot of different kind of ODBC connection types, you can set quote characters for SQL-clauses with optional parameter OdbcQuote.

  • OdbcQuoteCharacter.SQUARE_BRACKETS
  • OdbcQuoteCharacter.GRAVE_ACCENT
  • OdbcQuoteCharacter.NO_QUOTES

and the difference in executed SQL is:

1: 
2: 
3: 
SELECT [CourseID], [CourseName] FROM [Course] as [q] 
SELECT `CourseID`, `CourseName` FROM `Course` as `q` 
SELECT  CourseID ,  CourseName  FROM  Course  as  q 
1: 
2: 
3: 
4: 
[<Literal>] 
let quotechar = FSharp.Data.Sql.Common.OdbcQuoteCharacter.DEFAULT_QUOTE
type db2 = SqlDataProvider<Common.DatabaseProviderTypes.ODBC, dnsConn, OdbcQuote = quotechar>
let ctx2 = db2.GetDataContext()
Multiple items
type LiteralAttribute =
  inherit Attribute
  new : unit -> LiteralAttribute

Full name: Microsoft.FSharp.Core.LiteralAttribute

--------------------
new : unit -> LiteralAttribute
val connectionString : string

Full name: Odbc.connectionString
val connectionString2 : string

Full name: Odbc.connectionString2
val connectionString3 : string

Full name: Odbc.connectionString3
val resolutionPath : string

Full name: Odbc.resolutionPath
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Data

--------------------
namespace Microsoft.FSharp.Data
namespace FSharp.Data.Sql
val dnsConn : string

Full name: Odbc.dnsConn
type db = obj

Full name: Odbc.db
type SqlDataProvider

Full name: FSharp.Data.Sql.SqlDataProvider


<summary>Typed representation of a database</summary>
                    <param name='ConnectionString'>The connection string for the SQL database</param>
                    <param name='ConnectionStringName'>The connection string name to select from a configuration file</param>
                    <param name='DatabaseVendor'> The target database vendor</param>
                    <param name='IndividualsAmount'>The amount of sample entities to project into the type system for each SQL entity type. Default 1000.</param>
                    <param name='UseOptionTypes'>If true, F# option types will be used in place of nullable database columns. If false, you will always receive the default value of the column's type even if it is null in the database.</param>
                    <param name='ResolutionPath'>The location to look for dynamically loaded assemblies containing database vendor specific connections and custom types.</param>
                    <param name='Owner'>The owner of the schema for this provider to resolve (Oracle Only)</param>
                    <param name='CaseSensitivityChange'>Should we do ToUpper or ToLower when generating table names?</param>
                    <param name='TableNames'>Comma separated table names list to limit a number of tables in big instances. The names can have '%' sign to handle it as in the 'LIKE' query (Oracle and MSSQL Only)</param>
                    <param name='OdbcQuote'>Odbc quote characters: Quote characters for the table and column names: `alias`, [alias]</param>
                    <param name='SQLiteLibrary'>Use System.Data.SQLite or Mono.Data.SQLite or select automatically (SQLite only)</param>
                    
namespace FSharp.Data.Sql.Common
type DatabaseProviderTypes =
  | MSSQLSERVER = 0
  | SQLITE = 1
  | POSTGRESQL = 2
  | MYSQL = 3
  | ORACLE = 4
  | MSACCESS = 5
  | ODBC = 6

Full name: FSharp.Data.Sql.Common.DatabaseProviderTypes
Common.DatabaseProviderTypes.ODBC: Common.DatabaseProviderTypes = 6
val ctx : obj

Full name: Odbc.ctx
val quotechar : Common.OdbcQuoteCharacter

Full name: Odbc.quotechar
type OdbcQuoteCharacter =
  | DEFAULT_QUOTE = 0
  | GRAVE_ACCENT = 1
  | SQUARE_BRACKETS = 2
  | NO_QUOTES = 3
  | DOUBLE_QUOTES = 4
  | APHOSTROPHE = 5

Full name: FSharp.Data.Sql.Common.OdbcQuoteCharacter
Common.OdbcQuoteCharacter.DEFAULT_QUOTE: Common.OdbcQuoteCharacter = 0
type db2 = obj

Full name: Odbc.db2
val ctx2 : obj

Full name: Odbc.ctx2
Fork me on GitHub