I am trying to retrieve data from an access database on my C drive and i am getting the following error:
"Cannot start your application. The workgroup information file is missing or opened exclusively by another user."
the debugger shows the error in the following piece of code:
MyConnObj.Open _
"Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\<database>.mdb;" & _
"User ID=<username>;" & _
"Password=<pass>;"
how do i fix this error?
I have the following definitions:
Dim MyConnObj As New ADODB.Connection 'ADODB Connection Object
Dim myRecSet As New ADODB.Recordset 'Recordset Object
Dim sqlStr As String ' String variable to store sql command
Not sure, but that error means that you need to specify a Workgroup (system database) file.
Try to add this to your connection
MyConnObj.Open _
"Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\<database>.mdb;" & _
"Jet OLEDB:System Database=<path to system.mdw with information on username/pass>;" & _
"User ID=<username>;" & _
"Password=<pass>;"
in alternative, if your access mdb is not protected with a system.mdw file, you could try to remove the "User ID" and "Password" parts from the connection string.
Related
Access 365/Windows 10
I’m getting the “Could not find installable ISAM” error which I believe means I’ve a problem with my connection string below.
I did a right click, export on a single Access table to the MySQL backend so that I could link it and verify the driver, server, port, database, etc. of that connection against the connection string in the function below. It all looks good. Can you see what I've done wrong?
I have 128 tables to migrate to MySQL and am looking for a efficient, repeatable process; I had high hopes for this code...
'''
Public Function fncExportTables() As Boolean
'Declare Variables...
Dim strCnn As String
Dim rs As Recordset
Dim db As Database
Dim strTp As String
Dim strOriginal As String
'The Connection String required to connect to MySQL.
'I THINK THIS IS THE PROBLEM
strCnn = "DRIVER={MySQL ODBC 8.0 Driver};" & _
"SERVER=myServer;" & _
"PORT=24299;" & _
"DATABASE=myDb;" & _
"USER=myUserName;" & _
"PASSWORD=myPassword;" & _
"OPTION=3;"
strTp = "ODBC Database"
'Trap any Errors...
On Error GoTo Error_fncExportTables
'Open a recordset from the table the conatains
'all the table names we want to Link from the
'MySQL Database.
Set db = CurrentDb
Set rs = db.OpenRecordset("qselMgr", dbOpenSnapshot)
With rs
'Fill the Recordset...
.MoveLast
.MoveFirst
'Enumerate through the Records...
Do Until rs.EOF
'Place the Table Name into the str string variable.
' FieldName (below) would be the Field name in your Access
' Table which holds the name of the MySQL Tables to Link.
strOriginal = !strOriginalName
'Make sure we are not dealing will an empty string..
If Len(strOriginal) > 0 Then
'Link the MySQL Table to this Database.
'ERROR TRIGGERS ON THE LINE BELOW
DoCmd.TransferDatabase acExport, strTp, strCnn, _
acTable, strOriginal, strOriginal
End If
'move to the next record...
.MoveNext
Loop
End With
'We're done...
Exit_fncExportTables:
'Clear Variables and close the db connection.
Set rs = Nothing
If Not db Is Nothing Then db.Close
Set db = Nothing
Exit Function
Error_fncExportTables:
'If there was an error then display the Error Msg.
MsgBox "Export Table Error:" & vbCr & vbCr & _
Err.Number & " - " & Err.Description, _
vbExclamation, "Export Table Error"
Err.Clear
Resume Exit_fncExportTables
End Function
'''
Ok, i don't know if it will be useful but i want to share. Modos and admin will delete if they want.
I'm developping a VB application (actually, i migrate one from Excel VBA) to interact with MySQL Database.
I use VS 2019 16.8.2, Windows 7 x64.
I got a cryptic issue during connection to the database (using ADO, reference used: MS ADO 2.6).
Here's the code:
Public Sub test_connect()
Dim server_name As String
Dim database_name As String
Dim login_database As String
Dim port_number As String
Dim pwd_database As String
server_name = "my_server"
database_name = "my_database"
login_database = "whoisyourdaddy"
pwd_database = "youare"
connexion_dlweb_doc = New ADODB.Connection With {
.ConnectionString = "DRIVER={MySQL ODBC 8.0 ANSI Driver};" _
& "SERVER=" & server_name & "; " _
& "PORT=" & port_number & "; " _
& "DATABASE=" & database_name & "; " _
& "UID=" & login_database & "; " _
& "PWD=" & pwd_database & "; " _
& "OPTION=3"
}
If connexion_dlweb_doc.State <> adStateOpen Then
connexion_dlweb_doc.Open()
End If
End Sub
So, i got an exception with the " connexion_dlweb_doc = New ADODB.Connection" command. It's where it becomes cryptic:
System.TypeInitializationException : 'The type initializer for 'MyAPP.mod_declaration_variables' threw an exception.'
COMException : Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154 Classe non enregistrée (0x80040154 (REGDB_E_CLASSNOTREG)).
mod_declaration_variables is a module where i declare global variables like connexion_dlweb_doc:
Public connexion_dlweb_doc As ADODB.Connection
So, i asked my best friend google about this cryptic message and the CLSID {00020819-0000-0000-C000-000000000046} refer to...Microsoft.Interop.Excel 14.0.0.0
I use the reference MS Excel Objet Library 14.0 in my project. How did this interact with the ADO connection part? What's the link? Why the code crash here and not before?
I don't know why but the solution was to delete (or comment) every variable declaration using Excel library, e.g:
Public xlApp_arbo_wiki As Excel.Application
Guess it would help noobs like me.
I have been trying to connect mysql database to ms Access but no result.I don't think personally I am using the DAo.Connection and the workspace properly. I keep on getting the 3001 connection error when I set mySqlCon. I guess my arguments are not properly set but I was following an example from here.
Function connectingMySql()
Dim mySqlCon As Dao.Connection
Dim wrkODBC As Workspace
Set wrkODBC = CreateWorkspace("newODBCWorkspace", "admin", "", dbUseODBC)
Set mySqlCon = wrkODBC.OpenConnection("connection1", , , "DRIVER={MYSQL ODBC 5.1 DRIVER};" _
& "SERVER=testserver.com;port=3306;" _
& "DATABASE=test;" _
& "USER=root;" _
& "PASSWORD=pass;" _
& "Option=3;")
End Function
More infos:
Running Ms Access 2003
This MSDN page says that using dbUseODBC will cause a runtime error.
ODBCDirect workspaces are not supported in Microsoft Access 2010. Setting the type argument to dbUseODBC will result in a run-time error. Use ADO if you want to access external data sources without using the Microsoft Access database engine.
Try Set wrkODBC = CreateWorkspace("newODBCWorkspace", "admin", "")
After much struggle, I fixed it. Basically my arguments where wrong. Now I am getting a connection Error, which means the argument error has been fixed.
Function connectingMySql()
Dim mySqlCon As Dao.Connection
Dim wrkODBC As Workspace
Set wrkODBC = CreateWorkspace("newODBCWorkspace", "admin", "", dbUseODBC)
Set mySqlCon = wrkODBC.OpenConnection("DRIVER={MYSQL ODBC 5.1 DRIVER};" _
& "SERVER=testserver.com;port=3306;" _
& "DATABASE=test;" _
& "USER=root;" _
& "PASSWORD=pass;" _
& "Option=3;")
End Function
I have linked the sql server tables to ms access so that I can use ms access as the front end.I was able to access the tables from access, until I run into an error ODBC call failed when I tried to open one of the tables. There was no problem with the other tables. Actually I have changed a column name in sql server after creating a link. Is this the problem? I am really worried about this as I was about to use access as a front-end for my future purposes.
When you link to a remote table, Access stores metadata about that table. When you later change the table structure, the metadata doesn't get updated to capture the change.
Delete the link. Then recreate the link. That way the metadata will be consistent with the current version of the table.
Yes changing the column name after linking the table is most likely causing your failure. Is it is now trying to pull data from a column that no longer exists. You will need to relink the table. You can programatically link tables in access. We do that in may of our access applications and drive the tables that need to be linked from a local access table.
Public Sub LinkODBCTables()
Dim objRS As DAO.Recordset
Dim objTblDef As DAO.TableDef
Dim strTableName As String
Dim strAliasName As String
Dim strDSN As String
Dim lngTblCount As Long
Set objRS = CurrentDb.OpenRecordset( _
" select TableName," & _
" AliasName," & _
" DSN," & _
" DatabaseName," & _
" Development_DSN," & _
" UniqueIndexCol" & _
" from tblODBCLinkedTables " & _
" order by TableName", dbOpenSnapshot)
While Not objRS.EOF
' Check to see if we already have this linked tableDef
' We don't care if it is not actually in there
strTableName = objRS.Fields("TableName")
If Not IsNull(objRS.Fields("AliasName")) Then
strAliasName = objRS.Fields("AliasName")
Else
strAliasName = strTableName
End If
If DEV_MODE Then
strDSN = objRS.Fields("Development_DSN")
Else
strDSN = objRS.Fields("DSN")
End If
On Error Resume Next
CurrentDb.TableDefs.Delete strAliasName
If Err.Number <> 0 And _
Err.Number <> 3265 Then ' item not found in collection
Dim objError As Error
MsgBox "Unable to delete table " & strAliasName
MsgBox Err.Description
For Each objError In DBEngine.Errors
MsgBox objError.Description
Next
End If
On Error GoTo 0
Set objTblDef = CurrentDb.CreateTableDef(strAliasName)
objTblDef.Connect = g_strSQLServerConn & _
"DSN=" & strDSN & _
";DATABASE=" & objRS.Fields("DatabaseName") & _
";UID=" & g_strSQLServerUid & _
";PWD=" & g_strSQLServerPwd
objTblDef.SourceTableName = strTableName
On Error Resume Next
CurrentDb.TableDefs.Append objTblDef
If Err.Number <> 0 Then
Dim objErr As DAO.Error
For Each objErr In DBEngine.Errors
MsgBox objErr.Description
Next
End If
On Error GoTo 0
' Attempt to create a uniqe index of the link for updates
' if specified
If Not IsNull(objRS.Fields("UniqueIndexCol")) Then
' Execute DDL to create the new index
CurrentDb.Execute " Create Unique Index uk_" & strAliasName & _
" on " & strAliasName & "(" & objRS.Fields("UniqueIndexCol") & ")"
End If
objRS.MoveNext
Wend
objRS.Close
End Sub
We are using a single SQLServer login for our access applications so the g_strSQLServerUID and g_strSQLServerPwd are globals that contain that info. You may need to tweek that for your own needs or integrated security. We are setting up two DSNs one for production and the other for development. The DEV_MODE global controls wich set of DSNs are linked. You can call this code from a startup macro or startup form. It will deleted the old link and create a new link so you always have the most up to date schema.
I want to connect to the access 2010 database from excel.I am using VBA.I wrote the connection string as
Public objCon As New ADODB.Connection
objCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path & _
"\asset_database.accdb;ACE OLEDB:Database Password=password;"
But it is giving the error "could not find installable ISAM".What is this error?
Oddly enough, it is Jet OLEDB Password, not ACE:
objCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path _
& "\asset_database.accdb;Jet OLEDB:Database Password=password;"
See: http://www.connectionstrings.com/access-2007
Try "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ActiveWorkbook.Path & "\asset_database.accdb;JET OLEDB:Database Password=password;"
If you have Access installed, or you install the Access Database Engine on the workstation that has the Excel spreadsheet open, then you don't need to create an OLEDB connection; you can just open a database object as follows:
dim db as database
set db=opendatabase("c:\db path\my db.accdb")