sql - 'DefaultCatalog' 未声明。由于其保护级别,它可能无法访问。加上几个类似的错误
问题描述
我正在尝试连接到我的 LocalDB SQLEXPRESS 服务器上的数据库。我在另一个论坛上找到了代码,根据作者的说法,这可能是矫枉过正。我使用的所有代码都可以在这个 GitHub 链接上找到:
https://github.com/karenpayneoregon/DataGridViewConfiguration/tree/master/TeamLibrary
我使用的文件是: Class BaseExceptionProperties
、 ClassBaseSqlSrverConnections
和dataOperations
. 我附在 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
当然是因为默认情况下类是继承的,每个类不需要声明它们?我没有足够的经验来了解保护级别,是这样吗?
解决方案
您提到的属性BaseExceptionsHandler
在 github 存储库的类中定义。你忘了在你的项目中包含那个吗?
推荐阅读
- html - 当我尝试使用类“row”和一个 id 来定位一个 div 标签时,为什么我的 CSS 不工作?
- node.js - 电子远程网址显示不支持浏览器
- django-channels - 如何使用 nginx 和 django chanels 设置 gunicorn 和 uvicorn?
- html - 垂直的
推动 - flutter - Flutter 检查资产图像是否存在
- jquery - 如何使用 Bootstrap 类切换独占可见性?
- javascript - 使用中间件将用户路由到正确的页面。数据库中存在来自 POST 方法的给定值
- sql - 在 SQL 中,如何在 GROUP BY 子句中没有另外 5 个列的 SQL 列中对相同的值进行计数?
- excel - 如何复制和粘贴 A1 下的范围:A8 使用在跨行的 8 列数据集的开头重复的通用标识符
- firefox-addon - 从我的 firefox 扩展目录加载 html 文件