首页 > 解决方案 > 'DefaultCatalog' 未声明。由于其保护级别,它可能无法访问。加上几个类似的错误

问题描述

我正在尝试连接到我的 LocalDB SQLEXPRESS 服务器上的数据库。我在另一个论坛上找到了代码,根据作者的说法,这可能是矫枉过正。我使用的所有代码都可以在这个 GitHub 链接上找到: https://github.com/karenpayneoregon/DataGridViewConfiguration/tree/master/TeamLibrary 我使用的文件是: Class BaseExceptionProperties、 ClassBaseSqlSrverConnectionsdataOperations. 我附在 form1 上的代码如下:

Public Class Form1

    Private dataOperations As New DataOperations
    Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Dim dtCustomers = dataOperations.LoadCustomers()
        If ***dataOperations.IsSuccessFul*** Then
            ' do something with dtCustomers
        Else
            MessageBox.Show($"Encountered a problem, ***{dataOperations.LastExceptionMessage}")***
        End If
    End Sub

End Class

突出显示的文本表示它不是 dataOperations 的成员!此外,dataOperation 类中的以下内容表示它们未声明或由于其保护级别而可能无法访问:
DefaultCatalog
ConnectionString
mHasException
mLastException

当然是因为默认情况下类是继承的,每个类不需要声明它们?我没有足够的经验来了解保护级别,是这样吗?

标签: sqlvb.netvisual-studio

解决方案


您提到的属性BaseExceptionsHandler在 github 存储库的类中定义。你忘了在你的项目中包含那个吗?


推荐阅读