我不断遇到错误,说数据集、表适配器等..类型未定义

问题描述 投票:0回答:1

我正在使用 Visual Studio 2019 创建一个库存控制程序,并一直尝试将其链接到其中一个表单的 Access 数据库。

但是,当我编码时,我的笔记本电脑意外崩溃,之后设计器代码中出现了错误。我知道您不应该编辑此代码,因此我不确定导致这些问题的原因。

也由于这个原因,我的表单变成了空白,但所有按钮、文本框等的代码仍然存在。

我一直在研究解决方案,但我只是尝试任何修复,因为我不想让问题变得更糟。

我已经包含了设计者的代码和错误的屏幕截图。

任何帮助将不胜感激,因为我担心我因遗憾地单击“忽略并继续”而破坏了代码。

谢谢,

代码错误截图 错误页面截图

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class Stock_Control
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()>
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()>
    Private Sub InitializeComponent()
        Me.SuspendLayout()
        '
        'Stock_Control
        '
        Me.ClientSize = New System.Drawing.Size(284, 261)
        Me.Name = "Stock_Control"
        Me.ResumeLayout(False)

    End Sub

禁用警告 BC30002 '未定义类型“Stock_Control.StockControlDatabaseDataSet”。

Friend WithEvents StockControlDatabaseDataSet As Stock_Control.StockControlDatabaseDataSet

启用警告 BC30002 '未定义类型“Stock_Control.StockControlDatabaseDataSet”。

Friend WithEvents CustomerBindingSource As BindingSource

禁用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.CustomerTableAdapter'未定义。

Friend WithEvents CustomerTableAdapter As Stock_Control.StockControlDatabaseDataSetTableAdapters.CustomerTableAdapter

启用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.CustomerTableAdapter'未定义。

禁用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.TableAdapterManager'未定义。

Friend WithEvents TableAdapterManager As Stock_Control.StockControlDatabaseDataSetTableAdapters.TableAdapterManager

启用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.TableAdapterManager'未定义。

Friend WithEvents CustomerBindingNavigator As BindingNavigator
Friend WithEvents BindingNavigatorAddNewItem As ToolStripButton
Friend WithEvents BindingNavigatorCountItem As ToolStripLabel
Friend WithEvents BindingNavigatorDeleteItem As ToolStripButton
Friend WithEvents BindingNavigatorMoveFirstItem As ToolStripButton
Friend WithEvents BindingNavigatorMovePreviousItem As ToolStripButton
Friend WithEvents BindingNavigatorSeparator As ToolStripSeparator
Friend WithEvents BindingNavigatorPositionItem As ToolStripTextBox
Friend WithEvents BindingNavigatorSeparator1 As ToolStripSeparator
Friend WithEvents BindingNavigatorMoveNextItem As ToolStripButton
Friend WithEvents BindingNavigatorMoveLastItem As ToolStripButton
Friend WithEvents BindingNavigatorSeparator2 As ToolStripSeparator
Friend WithEvents CustomerBindingNavigatorSaveItem As ToolStripButton

禁用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.ItemTableAdapter'未定义。

Friend WithEvents ItemTableAdapter As Stock_Control.StockControlDatabaseDataSetTableAdapters.ItemTableAdapter

启用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.ItemTableAdapter'未定义。

Friend WithEvents Customer_IDTextBox As TextBox
Friend WithEvents FirstnameTextBox As TextBox
Friend WithEvents LastnameTextBox As TextBox
Friend WithEvents Street_AddressTextBox As TextBox
Friend WithEvents Town_CityTextBox As TextBox
Friend WithEvents PostcodeTextBox As TextBox
Friend WithEvents CountyTextBox As TextBox
Friend WithEvents New_CustomerCheckBox As CheckBox
Friend WithEvents ItemBindingSource As BindingSource

禁用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.OrderTableAdapter'未定义。

Friend WithEvents OrderTableAdapter As Stock_Control.StockControlDatabaseDataSetTableAdapters.OrderTableAdapter

启用警告 BC30002 '类型'Stock_Control.StockControlDatabaseDataSetTableAdapters.OrderTableAdapter'未定义。

    Friend WithEvents Item_IDTextBox As TextBox
    Friend WithEvents ItemTextBox As TextBox
    Friend WithEvents BrandTextBox As TextBox
    Friend WithEvents ColourTextBox As TextBox
    Friend WithEvents SizeTextBox As TextBox
    Friend WithEvents StyleTextBox As TextBox
    Friend WithEvents PopularityTextBox As TextBox
    Friend WithEvents Cost_of_ItemTextBox As TextBox
    Friend WithEvents Stock_LevelTextBox As TextBox
    Friend WithEvents Reorder_LevelTextBox As TextBox
    Friend WithEvents Out_of_Stock_LevelTextBox As TextBox
    Friend WithEvents Remaining_StockTextBox As TextBox
    Friend WithEvents OrderBindingSource As BindingSource
    Friend WithEvents Order_IDTextBox As TextBox
    Friend WithEvents Item_IDTextBox1 As TextBox
    Friend WithEvents Customer_IDTextBox1 As TextBox
    Friend WithEvents Sale_PriceTextBox As TextBox
    Friend WithEvents Delivery_ChargeTextBox As TextBox
    Friend WithEvents PromotionTextBox As TextBox
    Friend WithEvents Place_of_SaleTextBox As TextBox
    Friend WithEvents ReturnedCheckBox As CheckBox
    Friend WithEvents Date_of_SaleDateTimePicker As DateTimePicker
    Friend WithEvents Date_OrderedDateTimePicker As DateTimePicker
    Friend WithEvents Quanitity_OrderedTextBox As TextBox
    Friend WithEvents Cost_of_DeliveryTextBox As TextBox
    Friend WithEvents CustomerGroupBox As GroupBox
    Friend WithEvents ItemGroupBox As GroupBox
    Friend WithEvents OrderGroupBox As GroupBox
    Friend WithEvents OrderDataGridView As DataGridView
    Friend WithEvents DataGridViewTextBoxColumn1 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn2 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn3 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn4 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn5 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn6 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn7 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewCheckBoxColumn1 As DataGridViewCheckBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn8 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn9 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn10 As DataGridViewTextBoxColumn
    Friend WithEvents DataGridViewTextBoxColumn11 As DataGridViewTextBoxColumn
    Friend WithEvents CommandsGroupBox As GroupBox
    Friend WithEvents AddNewButton As Button
    Friend WithEvents Button3 As Button
    Friend WithEvents Button2 As Button
    Friend WithEvents Button4 As Button
    Friend WithEvents Button5 As Button
    Friend WithEvents KeywordTextBox As TextBox
End Class
vb.net forms error-handling windows-forms-designer designer
1个回答
0
投票

好吧,这有点像死线程,但我刚刚遇到了这个问题,它似乎完全是 Visual Studio 生成的代码的错误。

看看你的代码中如何指定它所抱怨的变量的 scope 未定义? 删除

Stock_Control.
前缀。

Friend WithEvents OrderTableAdapter As Stock_Control.StockControlDatabaseDataSetTableAdapters.OrderTableAdapter
变为
Friend WithEvents OrderTableAdapter As StockControlDatabaseDataSetTableAdapters.OrderTableAdapter
。我不知道为什么 Visual Studio 决定它生成的变量在该范围内,但它却无法在该范围内找到它们。

(我在向我的应用程序添加 DataGridView 时遇到了这个问题,它非常高兴地加载了列标题并让我用实际数据预览表,但是当我进行编译时,由于这些变量范围问题而因构建错误而失败。)

© www.soinside.com 2019 - 2024. All rights reserved.