While googling how to convert a BIT (YESNO) column in an access database to a checkbox programmatically, a possible solution I found was to copy an existing database's structure by using DoCmd.
I have added a reference to Microsoft.Office.Interop.Access and added those 2 lines in my code:
using Access = Microsoft.Office.Interop.Access;
Access.Application myAccessInstance = new Access.Application();
In the try block where I open a connection to my database I'm executing Do.Cmd.TransferDatabase:
myAccessInstance.DoCmd.TransferDatabase(0, "Microsoft Access", "C:\\Users\\user\\Desktop\\Merge\\playlists.MDB", 0, "PlaylistNames",
"PlaylistNamesCopy", true);
and I get a System.Runtime.InteropServices.COMException:
This operation requires an open database.
Does anyone know what is going wrong?
db=currentdbsets the variable db to an instance of the current database. You must remember that Access comes in two parts, the database side in Jet or ACE and the forms etc in the Access side. When you say you want to connect to the database, it all depends on what you want to do. If you want to manipulate tables and queries, you can use ADO and DAO. However, you wish to run VBA in Access, as far as I can see, which means you need a version of Access open. I do not think this is going to be the best approach for what you seem to wish to do.