Excluding sql scripts in Access DB
I have a script with several hundred sql queries that I need to execute on an access database. Since executing sql queries in Access is a bug IMO, you can only execute one at a time and not recognize comment lines starting with "-", I would like to know if there is an easier way to do this. Is there a good alternative to MS Access for managing DB access?
a source to share
Two decent options:
Option 1: Write a C # program that uses the DAO libraries to automate access and execution of programs programmatically.
dao.DBEngineClass dbengine = new dao.DBEngineClass();
dbengine.OpenDatabase(path, null, null, null);
dao.Database database = dbengine.Workspaces[0].Databases[0];
database.Execute(sql, null);
Option 2: Write a VBA module inside the database that will do the same using the method CurrentProject.Connection.Execute()
.
In any case, you can put this code inside a loop that reads your statements and executes them one at a time.
a source to share