[英]Visual Studio is not showing errors
我正在嘗試從本地數據庫-sdf文件中讀取數據。 我正在使用此代碼來獲取它:
Private Sub BookEdit_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Using conn As New SqlCeConnection("Data Source=|DataDirectory|Library.sdf;Persist Security Info=False")
conn.Open()
Dim comm = New SqlCeCommand("SELECT * FROM Book", conn)
Dim reader As SqlCeDataReader = comm.ExecuteReader()
While reader.Read()
MessageBox.Show(reader.GetString(0))
End While
End Using
End Sub
當我打開此窗體窗口時,它只是凍結然后關閉而沒有顯示任何錯誤。
工具->選項-> TextEditor-> C#->
在這里,我試圖打開編輯器中的Underline錯誤並顯示實時語義錯誤 。 但是我的代碼在VB.net中,所以當我為VB.NET打開相同的東西時,沒有此功能。
還試圖打開Option Strict
工具->選項->項目和解決方案-> VB默認值
但是沒有效果。 Visual Studio沒有顯示任何錯誤。 因此,我不知道在哪里可以修復連接到SDF文件並顯示我的Windows窗體的問題。
如何解決這個問題呢?
信息:Visual Studio 2012旗艦版Windows 8.1 Microsoft .NET Framework 4.5.51641
我只是想幫忙。 而且我想您可能必須關閉conn和SqlCeDataReader對象,如下所示。 或者,進一步,您可能希望將代碼放入Try-Catch塊中。
Private Sub BookEdit_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Using conn As New SqlCeConnection("Data Source=|DataDirectory|Library.sdf;Persist Security Info=False")
conn.Open()
Dim comm = New SqlCeCommand("SELECT * FROM Book", conn)
Dim reader As SqlCeDataReader = comm.ExecuteReader()
While reader.Read()
MessageBox.Show(reader.GetString(0))
End While
reader.Close()
conn.Close()
End Using
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.