OleDbException 'unspecified error'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maylortaylor
    New Member
    • Nov 2012
    • 72

    OleDbException 'unspecified error'

    So, i get the OleDBException "unspecifie d error" whenever the function below hits the
    Code:
    dataAdapter.Fill(dataset)
    line.

    I have tried adding
    Code:
    dbcommand.connection.close()
    and
    Code:
    dbcommand.connection.dispose
    () but neither fixed the problem.

    I assume that this error would happen every time i try to connect with the DB but this is just the first function that does so in my code, so this is where the error is first occuring.

    I have read online that MS Access will eventually clear out old connections after a while, if this is true, then i should just have to wait..but i dont want to keep waiting for nothing to happen.

    Code:
     Function GetOrders(ByVal _numberrecords As Long) As DataTable
            Dim TaxConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ConfigurationManager.AppSettings("Database")
            Dim dbConnection As OleDbConnection = New OleDbConnection(TaxConnStr)
            Try
                'Code to get orders in call status. Sort oldest to newest
                ' dbConnection.Open()
                Dim queryString As String
                queryString = "SELECT TOP " & _numberrecords & " Orders.Control_Number, Orders.State, Orders.County, Orders.Status, Orders.ZipCode, Orders.OrderNumber, Orders.Client, Orders.Department "
                queryString += "FROM Orders "
                queryString += "WHERE(((Orders.Status) = 'Tax Cert Call' Or (Orders.Status) = 'Online')) "
                queryString += "ORDER BY Orders.Date_Received;"
                Dim dbCommand As OleDbCommand = New OleDbCommand
                dbCommand.CommandText = queryString
                dbCommand.Connection = dbConnection
                Dim dataAdapter As OleDbDataAdapter = New OleDbDataAdapter
                dataAdapter.SelectCommand = dbCommand
                Dim dataSet As DataSet = New DataSet
                dataAdapter.Fill(dataSet)
    
                If dataSet.Tables(0).Rows.Count >= 1 Then
                    GetOrders = dataSet.Tables(0)
                End If
    
            Catch ex As OleDbException
                Console.WriteLine(ex.Message)
                myLogger.Log(ex.Message)
            Finally
                dbConnection.Close()
    
                dbConnection.Dispose()
            End Try
    
    
        End Function
  • vijay6
    New Member
    • Mar 2010
    • 158

    #2
    Hey maylortaylor, line number 21 is correct in your 4th code?

    Comment

    • maylortaylor
      New Member
      • Nov 2012
      • 72

      #3
      Is there no one out there that can help me? Is this really that hard of a problem? And yes, Vijay, it's correct.

      Comment

      • maylortaylor
        New Member
        • Nov 2012
        • 72

        #4
        Found the problem. My Access Database was corrupted. I just remade it and my program worked fine.

        Comment

        Working...