任何想法爲什麼我會得到一個與SqlConnection錯誤說法類型預期代碼BC30182,它幾乎就像它不導入System.Data.SqlClient。我使用VS 2015VB.net中SQL連接類的問題
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class SQLControl
Public SQLCon As New SqlConnection With {.ConnectionString = "Server=localhost;DataBase=DBname;Trusted_Connection=True;"}
Public SQLcmd As SqlCommand
Public Function HasConnection() As Boolean
Try
SQLCon.open
SQLCon.Close()
Catch ex As Exception
End Try
End Function
End Class
在.net小提琴中編譯得很好(在添加'Imports System'後,Visual Studio VB項目中不需要這樣做)。錯誤消息的確切內容是什麼? – Heinzi
http://prntscr.com/8s7i7g以下是VS – Wally
的屏幕截圖您是否在項目中引用了System.Data.dll? – Heinzi