fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
572 stars 146 forks source link

Using SQLProvider with ODBC #596

Closed zet4080 closed 5 years ago

zet4080 commented 5 years ago

Hi!

I try to use SQLProvider for an ODBC connect, but can't get it to work with VisualStudio 2017 (Community).

I added SQLProvider with NuGet and it shows up in the dependencies. I can open it with

open FSharp.Data.Sql

and autocomplete of VisualStudio offers me ODBC when typing

Common.DatabaseProviderTypes.ODBC

But this code

  open FSharp.Data.Sql

  [<Literal>] 
  let dnsConn = @"DSN=foo" 

  type db = SqlDataProvider<Common.DatabaseProviderTypes.ODBC, dnsConn>

gives me an error:

FS3033 Der Typanbieter 'FSharp.Data.Sql.SqlTypeProvider' hat einen Fehler gemeldet: Unsupported database provider: ODBC

Any help would be appreciated!

Thanks!

Thorium commented 5 years ago

Have you set up your DSN to windows? This error sounds like it's not SQLProvider error but the underlying Odbc driver error.

zet4080 commented 5 years ago

Yes, I did. DSN-Test Connection to the database succeeds. Also it is a compile error respectively Visual Studio directly marks the line type db = SqlDataProvider<Common.DatabaseProviderTypes.ODBC, dnsConn> as erroneous. I really don't know how this works internally, but I would think that it should be a runtime error if there is something wrong with the ODBC setup?

Thanks again!

Thorium commented 5 years ago

It's also a compile time error, as F# is doing connection to database to fetch the shape of objects (data tables, etc.).

zet4080 commented 5 years ago

It was a security issue on the database. While connect was allowed, reading the schema-data was denied.

I found it by doing a connect with System.data.Odbc, which gave me the correct error message "access denied" ... Sorry for the inconvenience - but the error message was misleading me :-( Thanks for your time!