有谁可以告诉我为什么我的代码会给我System.Data.OleDb.OleDbException
和IErrorInfo.GetDescription failed with E_FAIL(0x80004005)
错误?他们在同一个地方。错误出现在Reader = Command.ExecuteReader()
行。这是我的代码:
If Not Page.IsPostBack Then
Dim Connection As OleDbConnection
Dim Command As OleDbCommand
Dim Reader As OleDbDataReader
Dim ConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\KayJoy\Documents\University\UJ Official Documents\Informatics\2A\P02.accdb"
Connection = New OleDbConnection(ConnectionString)
Connection.Open()
Dim CommandString As String
CommandString = "SELECT * FROM Module"
Command = New OleDbCommand(CommandString, Connection)
Command.CommandType = CommandType.Text
Reader = Command.ExecuteReader()
If Reader.HasRows Then
Do While Reader.Read
Response.Write(Reader("M_Code") & ",")
Response.Write(Reader("M_Name") & ",")
Response.Write(Reader("M_Credit") & "<br/>")
Loop
End If
Command.Connection.Close()
Command.Dispose()
Connection.Dispose()
End If