By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

OleDbException 'unspecified error'

maylortaylor
P: 72
So, i get the OleDBException "unspecified error" whenever the function below hits the
Expand|Select|Wrap|Line Numbers
  1. dataAdapter.Fill(dataset)
line.

I have tried adding
Expand|Select|Wrap|Line Numbers
  1. dbcommand.connection.close()
and
Expand|Select|Wrap|Line Numbers
  1. 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.

Expand|Select|Wrap|Line Numbers
  1.  Function GetOrders(ByVal _numberrecords As Long) As DataTable
  2.         Dim TaxConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ConfigurationManager.AppSettings("Database")
  3.         Dim dbConnection As OleDbConnection = New OleDbConnection(TaxConnStr)
  4.         Try
  5.             'Code to get orders in call status. Sort oldest to newest
  6.             ' dbConnection.Open()
  7.             Dim queryString As String
  8.             queryString = "SELECT TOP " & _numberrecords & " Orders.Control_Number, Orders.State, Orders.County, Orders.Status, Orders.ZipCode, Orders.OrderNumber, Orders.Client, Orders.Department "
  9.             queryString += "FROM Orders "
  10.             queryString += "WHERE(((Orders.Status) = 'Tax Cert Call' Or (Orders.Status) = 'Online')) "
  11.             queryString += "ORDER BY Orders.Date_Received;"
  12.             Dim dbCommand As OleDbCommand = New OleDbCommand
  13.             dbCommand.CommandText = queryString
  14.             dbCommand.Connection = dbConnection
  15.             Dim dataAdapter As OleDbDataAdapter = New OleDbDataAdapter
  16.             dataAdapter.SelectCommand = dbCommand
  17.             Dim dataSet As DataSet = New DataSet
  18.             dataAdapter.Fill(dataSet)
  19.  
  20.             If dataSet.Tables(0).Rows.Count >= 1 Then
  21.                 GetOrders = dataSet.Tables(0)
  22.             End If
  23.  
  24.         Catch ex As OleDbException
  25.             Console.WriteLine(ex.Message)
  26.             myLogger.Log(ex.Message)
  27.         Finally
  28.             dbConnection.Close()
  29.  
  30.             dbConnection.Dispose()
  31.         End Try
  32.  
  33.  
  34.     End Function
May 17 '13 #1

✓ answered by maylortaylor

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

Share this Question
Share on Google+
3 Replies


100+
P: 158
Hey maylortaylor, line number 21 is correct in your 4th code?
May 18 '13 #2

maylortaylor
P: 72
Is there no one out there that can help me? Is this really that hard of a problem? And yes, Vijay, it's correct.
May 20 '13 #3

maylortaylor
P: 72
Found the problem. My Access Database was corrupted. I just remade it and my program worked fine.
May 20 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.