Visual Studio generates errors when using a DataSet with SQL server 2019

Max Santeramo 21 Reputation points
2022-05-28T16:35:50.63+00:00

Hi everyone I am following a course to learn .NET based Visual Studio and SQL Server.
Unfortunately, the versions featured are earlier than SQL Server 2019 and Visual Studio 2022 which were the ones available when I started.
I am working on a Dataset and a Table adapter and all was fine, connections ok and so on, but when I open the Data Source window my data source is not available and the window shows “This window is not supported for the selected object” message.
If I try to run the application I get a bunch of errors like this
Severity Code Description Project File Line Suppression State
Error BC30002 Type 'Global.System.Data.SqlClient.SqlConnection' is not defined. market_app2 C:\DEV Visual Studio\Repos\market_app2_sn\market_app2\Dataset\Goods_ds.Designer.vb 827 Active

Referring to the following portion of code, which is automatically generated. Can anyone help me? What can I do to solve this? I am stuck !

'''<summary>
'''Represents the connection and commands used to retrieve and save data.
'''</summary>
<Global.System.ComponentModel.DesignerCategoryAttribute("code"), _
Global.System.ComponentModel.ToolboxItem(true), _
Global.System.ComponentModel.DataObjectAttribute(true), _
Global.System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner"& _
", Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), _
Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")> _
Partial Public Class goods_listTableAdapter
Inherits Global.System.ComponentModel.Component

    Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter

    Private _connection As Global.System.Data.SqlClient.SqlConnection

    Private _transaction As Global.System.Data.SqlClient.SqlTransaction

    Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand

    Private _clearBeforeFill As Boolean

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")>  _
    Public Sub New()
        MyBase.New
        Me.ClearBeforeFill = true
    End Sub

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")>  _
    Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
        Get
            If (Me._adapter Is Nothing) Then
                Me.InitAdapter
            End If
            Return Me._adapter
        End Get
    End Property

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")>  _
    Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection
        Get
            If (Me._connection Is Nothing) Then
                Me.InitConnection
            End If
            Return Me._connection
        End Get
        Set
            Me._connection = value
            If (Not (Me.Adapter.InsertCommand) Is Nothing) Then
                Me.Adapter.InsertCommand.Connection = value
            End If
            If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then
                Me.Adapter.DeleteCommand.Connection = value
            End If
            If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then
                Me.Adapter.UpdateCommand.Connection = value
            End If
            Dim i As Integer = 0
            Do While (i < Me.CommandCollection.Length)
                If (Not (Me.CommandCollection(i)) Is Nothing) Then
                    CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value
                End If
                i = (i + 1)
            Loop
        End Set
    End Property

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")>  _
    Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction
        Get
            Return Me._transaction
        End Get
        Set
            Me._transaction = value
            Dim i As Integer = 0
            Do While (i < Me.CommandCollection.Length)
                Me.CommandCollection(i).Transaction = Me._transaction
                i = (i + 1)
            Loop
            If ((Not (Me.Adapter) Is Nothing)  _
                        AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then
                Me.Adapter.DeleteCommand.Transaction = Me._transaction
            End If
            If ((Not (Me.Adapter) Is Nothing)  _
                        AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then
                Me.Adapter.InsertCommand.Transaction = Me._transaction
            End If
            If ((Not (Me.Adapter) Is Nothing)  _
                        AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then
                Me.Adapter.UpdateCommand.Transaction = Me._transaction
            End If
        End Set
    End Property

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")>  _
    Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand()
        Get
            If (Me._commandCollection Is Nothing) Then
                Me.InitCommandCollection
            End If
            Return Me._commandCollection
        End Get
    End Property
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,328 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,607 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,560 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 26,111 Reputation points Microsoft Vendor
    2022-05-30T02:13:42.22+00:00

    Hi @Max Santeramo ,
    In the ( Create a new project ) window select Windows Form App(.NET Framework) NOT Windows Form App (.NET).
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful