Git Product home page Git Product logo

Comments (5)

smoothdeveloper avatar smoothdeveloper commented on August 15, 2024

@houdelou thanks for the report, could you add "nuget System.Data.SqlClient" to your paket.dependencies file, generate the scripts again, and reference that package before referencing FSharp.Data.SqlClient one?

Here is a very crude script referencing through nuget, but you can replace it with #load statements for the same packagess using paket as well, note that somehow, it is needed to evaluate importing System.Data.SqlClient, so I've put ;; to force this evaluation:

#r "nuget: System.Data.SqlClient";;
#r "nuget: FSharp.Data.SqlClient"

open System.Data.SqlClient
let [<Literal>] cn = "Server=server;Database=dbname;User Id=user;Password=password;"

type Q = FSharp.Data.SqlCommandProvider< "select * from sys.tables", cn>

let cnx = new SqlConnection(cn)
cnx.Open()
let q = Q(cnx)
let results = q.Execute() |> Seq.toArray
printfn $"hello %A{results}"

Please let me know if this helps.

from fsharp.data.sqlclient.

houdelou avatar houdelou commented on August 15, 2024

@smoothdeveloper Thank you for your help. I copied your code into a script file and I still get the same error message. Interesting approach though with the ";;". Are you also using .NET 6 ? I think I could try with other framework versions. .NET 6 is recent so maybe there is not enough dev using it yet ? I'll try to create a new project to see if it might work. Thanks again.

from fsharp.data.sqlclient.

houdelou avatar houdelou commented on August 15, 2024

Is it possible that the project references System.Data.SqlClient instead of its successor Microsoft.Data.SqlClient ? Can it be the problem I'm having ?

https://learn.microsoft.com/en-us/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace?view=sql-server-ver16

from fsharp.data.sqlclient.

smoothdeveloper avatar smoothdeveloper commented on August 15, 2024

@houdelou, I'm not reproducing using my sample script in VS 2022 or from dotnet fsi command line, both works ok.

I'd suggest you first try to make use of a plain System.Data.SqlServer ado.net provider in your environment, to make sure we have a base plate which works, disregarding this library.

Regarding Microsoft.Data.SqlClient, it is not supported in this library for now, but there are discussions: #374 about it.

from fsharp.data.sqlclient.

houdelou avatar houdelou commented on August 15, 2024

@smoothdeveloper Ok now it seems to be working with ";;" at the end of the line. I did a couple of tests and finally it worked when I restarted the interpreter. Thanks ! Problem solved

from fsharp.data.sqlclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.