So, i get the OleDBException "unspecifie d error" whenever the function below hits the
line.
I have tried adding
and
() 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:
dataAdapter.Fill(dataset)
I have tried adding
Code:
dbcommand.connection.close()
Code:
dbcommand.connection.dispose
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
Comment