0

I am calling a vb.net function of a dll from below VBA code in MDB. I am calling Get_GDW_data_final sub from immediate Window.

Public Sub Get_GDW_data_final()
Dim r As New Get_GDW_Data.GDW
MsgBox r.DetailedWork()
End Sub

I have created Get_GDW_Data.dll added reference of it in MDB.

The coding of class is as below.

Public Class GDW
    Public Function DetailedWork()
        Dim lastrow As Long
        Dim ADODBcnn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Access8\W156_RocketOffset_Backup.mdb;Persist Security Info=False;Mode=read")
        Dim ADODBcmd As New OleDb.OleDbCommand
        Dim ADODBcmd1 As New OleDb.OleDbCommand
        Dim ADODBrst As OleDb.OleDbDataReader
        ADODBcnn.Open()
        ADODBcmd.CommandText = "select count(*) from input"
        lastrow = ADODBcmd.ExecuteScalar()
        ADODBcnn.Close()
        Return lastrow.ToString()

    End Function
End Class

Here I am getting error

Run-time Error -2147467259 (80004005) The database has been put in a state by admin or machine 'Rachit' that prvents it from being opened or locked.

user229044
  • 232,980
  • 40
  • 330
  • 338

2 Answers2

1

I discovered what the problem was:

It's a Limitation of Access that you can not access a table of a database using a dll from which you are calling the function :-)

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
0

INPUT is a reserved word, so try:

ADODBcmd.CommandText = "select count(*) from [input]"
Gustav
  • 53,498
  • 7
  • 29
  • 55
  • Yes I did that already but That is not the reason of that error. The issue is the database is already open and I am calling sub from the immediate window which calls a .net function which tries to access table of the database which is already open. kind of simultaneous connectin issue. – rachit jani Nov 19 '15 at 11:26