Link to home
Start Free TrialLog in
Avatar of ayha1999
ayha1999

asked on

Datareader error

HI,

has anyone encountered the " IErrorInfo.GetDescription failed with E_FAIL(0x80004005)" error before. I get this error when I use oledbdatareader with access2000.

the detail of the error is;

System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005). at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at WeaponShop.frmUpSchedule.Page_Load(Object sender, EventArgs e) in

could anyone hep to get rid of this error?

ayha
Avatar of JessyEzzy
JessyEzzy

It would help if you post the code where you get the error
Avatar of ayha1999

ASKER

Hi,

this is complete code;

 Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        QID = Request.QueryString("IntID")
    Dim con As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("connectionString"))

        Dim str As String = "select Schedules.*,UnitName,Interval from (Schedules LEFT JOIN Units ON Schedules.UnitCode=Units.UnitCode)LEFT JOIN MaintInt ON Schedules.SInt=MaintInt.IntID Where SchID=@IntID"
        Dim cmd As OleDbCommand = New OleDbCommand(str, con)
      ...
               con.Open()
           Try
            Dim dr As OleDbDataReader = cmd.ExecuteReader()
            If dr.Read Then
                txtSchID.Text = QID
                txtUnit.Text = dr.Item("UnitName")

                txtBegDate.Text = DateTime.Parse(dr.Item("FromDate")).ToShortDateString
                txtEndDate.Text = DateTime.Parse(dr.Item("ToDate")).ToShortDateString

                Dim lstMID As ListItem = ddlMaintInt.Items.FindByText(CStr(dr.Item("Interval")))
                If lstMID Is Nothing Then
                    lstMID.Selected = True
                End If

                txtSpReq.Text = dr.Item("Req")
                txtRemarks.Text = dr.Item("Remarks")
            End If

        Catch ex As OleDbException
         ...
        Finally
         ...
        End Try
    End Sub

ayha
You are receiving the error at this line "Dim dr As OleDbDataReader = cmd.ExecuteReader()" ?

one more thing you said that you receive the error when you use oledbdatareader with Access 2000, does this mean that you tried something else and it worked but now it's not working with access 2000?
Hi,

I just get this error at 'cmd.executereader(). I didn't try anything else.

ayha
Having an error at the line executing the reader usually means that there is something wrong with the query itself, I noticed in your code that you are not passing the value of the parameter IntID, another thing with Oledb we use the ? as a palceholder for the input parameter, so you query would be something like this

Dim str As String = "select Schedules.*,UnitName,Interval from (Schedules LEFT JOIN Units ON Schedules.UnitCode=Units.UnitCode)LEFT JOIN MaintInt ON Schedules.SInt=MaintInt.IntID Where SchID= ?"

cmd.CommandType = CommandType.Text
cmd.Parameters.Add("@SchID",OleDbType.Integer).Value = ' your required value

if this didn't help, try executing your query as it is in the access and see what errors it will report to you

HTH Jessy
Hi JessyEzzy,

The error was the word 'Interval' in the query. I just changed the name to some other name and it worked. When I executed the query with Interval in the access query it was working fine. I think the datareader doesn't recognize the 'INterval' as a field name.

thanks for your interest.

ayha
Glad to hear you solve it.

Good Luck.
ASKER CERTIFIED SOLUTION
Avatar of Lunchy
Lunchy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial