question

MaxSanteramo-2158 avatar image
0 Votes"
MaxSanteramo-2158 asked MaxSanteramo-2158 commented

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

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
sql-server-generaldotnet-visual-basicdotnet-adonet
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JiachenLiMFST-9349 avatar image
1 Vote"
JiachenLiMFST-9349 answered MaxSanteramo-2158 commented

Hi @MaxSanteramo-2158 ,
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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Jiachen, thank you SO much, it worked like a charm, this was really, really useful, it totally solved the issue. THANK YOU!

0 Votes 0 ·