IErrorInfo.GetDescription failed with E_FAIL(0x80004005)
-
I get the following error while trying to access an msacccess database ,i cant seem to figure it out,the error is IErrorInfo.GetDescription failed with E_FAIL(0x80004005). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005). Source Error: Line 20: SQLString = "SELECT DISTINCT Position FROM applicant ORDER BY position" Line 21: DBCommand = New OleDbCommand(SQLString, DBConnection) Line 22: DBReader = DBCommand.ExecuteReader() Line 23: Line 24: While DBReader.Read() the source code that generate d error is as follows <%@ Page Language="vb" Debug="true" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Drawing" %> Sub Page_Load Dim DBConnection As OleDbConnection Dim DBCommand As OleDbCommand Dim DBReader As OleDbDataReader Dim SQLString As String Dim Counter As Integer = 0 DBConnection = New OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("miraflash.mdb")) DBConnection.Open() SQLString = "SELECT DISTINCT Position FROM applicant ORDER BY position" DBCommand = New OleDbCommand(SQLString, DBConnection) DBReader = DBCommand.ExecuteReader() While DBReader.Read() Dim MyButton as New Button MyButton.Text = DBReader("position") MyButton.CommandName = DBReader("position") MyButton.Width = Unit.Parse("100px") MyButton.Font.Size = FontUnit.Parse("8pt") AddHandler MyButton.Command, AddressOf Get_Books ButtonArea.Controls.Add(MyButton) Dim MyBlank As New Literal MyBlank.Text = " " ButtonArea.Controls.Add(MyBlank) Counter += 1 If Counter Mod 3 = 0 Then Dim MyBreak As New Literal MyBreak.Text = "<br/>" ButtonArea.Controls.Add(MyBreak) End If End While DBReader.Close() DBConnection.Close() End Sub Sub Get_Books (Src as Object, Args As CommandEventArgs) Dim SQLString As String SQLString = "SELECT ID, Surname, Firstname, middlename FROM applicant " & _ "WHERE position = '" & Args.CommandName & "' " & _ "ORDER BY ID" BookSource.SelectCommand = SQLString End Sub
-
I get the following error while trying to access an msacccess database ,i cant seem to figure it out,the error is IErrorInfo.GetDescription failed with E_FAIL(0x80004005). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005). Source Error: Line 20: SQLString = "SELECT DISTINCT Position FROM applicant ORDER BY position" Line 21: DBCommand = New OleDbCommand(SQLString, DBConnection) Line 22: DBReader = DBCommand.ExecuteReader() Line 23: Line 24: While DBReader.Read() the source code that generate d error is as follows <%@ Page Language="vb" Debug="true" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Drawing" %> Sub Page_Load Dim DBConnection As OleDbConnection Dim DBCommand As OleDbCommand Dim DBReader As OleDbDataReader Dim SQLString As String Dim Counter As Integer = 0 DBConnection = New OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("miraflash.mdb")) DBConnection.Open() SQLString = "SELECT DISTINCT Position FROM applicant ORDER BY position" DBCommand = New OleDbCommand(SQLString, DBConnection) DBReader = DBCommand.ExecuteReader() While DBReader.Read() Dim MyButton as New Button MyButton.Text = DBReader("position") MyButton.CommandName = DBReader("position") MyButton.Width = Unit.Parse("100px") MyButton.Font.Size = FontUnit.Parse("8pt") AddHandler MyButton.Command, AddressOf Get_Books ButtonArea.Controls.Add(MyButton) Dim MyBlank As New Literal MyBlank.Text = " " ButtonArea.Controls.Add(MyBlank) Counter += 1 If Counter Mod 3 = 0 Then Dim MyBreak As New Literal MyBreak.Text = "<br/>" ButtonArea.Controls.Add(MyBreak) End If End While DBReader.Close() DBConnection.Close() End Sub Sub Get_Books (Src as Object, Args As CommandEventArgs) Dim SQLString As String SQLString = "SELECT ID, Surname, Firstname, middlename FROM applicant " & _ "WHERE position = '" & Args.CommandName & "' " & _ "ORDER BY ID" BookSource.SelectCommand = SQLString End Sub
I read somewhere else that this error could be caused by using reserved words in your query. Try adding square brackets around your table and field names: e.g. SELECT DISTINCT [Position] FROM [applicant] ORDER BY [position]