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
で、データベースにはパスワードが設定されていません。