How to Import Data from Microsoft Access?

One of the possible options of importing data to Soley Studio is from Microsoft Access Databases. There are, however, no built-in import functions for this type of database. Therefore, this article provides the steps to be taken in order to import from Microsoft Access *.accdb files. Furthermore, the accompanying code is attached.

How to enable MS Access Importing

  1. Download Microsoft Access Database Engine 2010 Redistributable (64-bit version) from https://www.microsoft.com/en-us/download/details.aspx?id=13255 and install it. This is if you are using a 64bit installation of Soley Studio. If you use the 32bit version please get the 32bit  Microsoft Access Database Engine 2010. If you are not sure which version of Soley Studio you use open Soley Studio and go to Help –> About in the top menu.
  2. Add your Access Database file to the Data folder of your Project.
  3. Create a new ruleset in your project. Add the code attached to this article.
  4. Change the Database file path, Node type, Columns selected.
  5. Run the sequence

Error messages can be found in the folder Project/Data in the text file “importMSAccess.txt”.

 

/*
* Created with Soley Studio Professional
*/

sequence importMSAccess {
	//{clear()} ;>
	
	(dbFile:string) ;> 
	{ dbFile = _io_getProjectFullPath(" ENTER_relative_path_of_the_database_e.g._Data\\.. ")} ;>
		
	(connStr:string) ;> 	
	{ connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dbFile + ";"} ;>
	
	importNorthwind3(connStr) ;>
	
	{emit ("importMSAccess finished")} 
}

sequence importNorthwind3(connStr:string) {
	
	(queryProducts:string = "select * from ENTER_name_of_the_table_you_are_importing_from;") ;>	
	
	 ImportOleDbTypedNodeListAttrMapping (connStr, queryProducts, "ENTER_node_class_you_are_importing_to", 
		map<int,string>{1->"ENTER_attribute_name1", 2->"ENTER_attribute_name2", CONTINUE_If_Needed}, 
		_io_getProjectFullPath("Data\\importMSAccess.txt") ) 
}


The  ImportOleDbTypedNodeListAttrMapping  function comes with Soley Studio Professional. Alternatively, the library functions for importing from databases can be purchased in Soley.

Was this article helpful?