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.
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 :-)