Function SQLSelect() As ActionResult
Dim theconnection As New SqlConnection("Data Source=(localdb);Database=test_drive_database;")
Dim queryString As String = "SELECT * FROM ColorTable"
Dim command As New SqlCommand(queryString)
command.CommandTimeout = 15
command.CommandType = CommandType.Text
'Printing Out the SQL Result
Return ViewData("command")
End Function
我有一个空的 SQL 结果,没有错误消息。
调用上述函数的 URL 是:http://localhost:1812/Home/SQLSelect
问题是,有没有办法专门检查 SQL 数据库是否已打开?
使用的工具: Visual Studio 2012、VB.NET MVC 4、Microsoft SQL Server Compact 4.0
注意: 数据库名称为test_drive_database
,数据库没有设置密码。