Question

Je suis nouveau dans SQL Server PVT et essayer de comprendre les bases. J'ai créé un échantillon dans la base de données PVT Northwind dans SQL Express. Mon code de VB.NET est assez simple (voir ci-dessous). Le paramètre est vide PVT dans la procédure. Je l'ai testé le PVT dans SQL Server et il fonctionne très bien. Des idées? Est-ce que SQL Express supporte entièrement les paramètres de valeur de table?

    Dim dt As DataTable = New DataTable()
    dt.Columns.Add("RegionID", GetType(Int64))
    dt.Columns.Add("RegionDesc", GetType(String))
    dt.Rows.Add(21, "FromProgram2")
    dt.Rows.Add(22, "FromProgram3")

    Try
        If dt.Rows.Count > 0 Then
            Dim mycommand As SqlCommand = New SqlCommand
            Dim myconn As SqlConnection = New SqlConnection(connstring)
            mycommand.CommandText = "dbo.TestType"
            mycommand.Connection = myconn
            Dim param1 As SqlParameter = mycommand.Parameters.AddWithValue("@RegionData", dt)
            param1.SqlDbType = SqlDbType.Structured
            param1.TypeName = "dbo.RegionType"
            mycommand.Connection.Open()
            mycommand.ExecuteNonQuery()
            mycommand.Connection.Close()
            Console.WriteLine("")
            Console.ReadLine()
        Else
            Console.Write("No data in datatable")
            Console.ReadLine()
        End If

    Catch ex As Exception
        Console.WriteLine(ex.Message)
        Console.ReadLine()
    End Try
Était-ce utile?

La solution

Problème résolu. Ce fut un problème avec mon installation à la maison.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top