TargetParameterCountException when running Fsharp query

Hey,
Some time ago I reported a bug via the report bug menu in linqpad (at least I hope so).
Since the following code still throws a targetparametercountexception in the lastet beta I am reposting here just in case my email did not arrive. The snippet connects to a local SqlServerExpress 2014 instance and tries to query a Table called Table_1.

SQL:
CREATE DATABASE [BlaBla] GO USE [BlaBla] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Table_1]([Id] [int] NOT NULL, CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED ([Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY] GO
FSharp (LinqPad selection: F# Program, Connection = None):
open System.Data.SqlClient [<EntryPoint>] let main args = use s = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=BlaBla;Integrated Security=True") s.Open() use c = s.CreateCommand() c.CommandText <- "SELECT * FROM Table_1" use r = c.ExecuteReader() while r.Read() do let arr:obj array = Array.zeroCreate r.FieldCount r.GetValues(arr) |> ignore printfn "%A" arr 0

Thanks in advance.

Comments

  • Sorry for the delay - I'll look in this in next week.
  • This will now run as-is without error in the latest beta:
    http://www.linqpad.net/download.aspx#beta

    I presume you're aware that the following code will work without error in all versions of LINQPad:
    open System.Data.SqlClient
    
    let s = new SqlConnection("Data Source=.;Initial Catalog=BlaBla;Integrated Security=True")
    s.Open()
    let c = s.CreateCommand()
    c.CommandText <- "SELECT * FROM Table_1"
    let r = c.ExecuteReader()
    while r.Read() do
        let arr:obj array = Array.zeroCreate r.FieldCount
        r.GetValues(arr) |> ignore
        printfn "%A" arr
  • edited August 4
    Thank you.
    I just tested this and it works just fine.
    Unfortunately (at least to my understanding) I cannot just use the dot because the server I aim to run this at has multiple named Instances of SQL Server running.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!