Evridb examples: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Scott
(Created page with '__TOC__ ==Examples use EVRI Database Object== NOTE: For PLS_Toolbox 6.1 and newer. ===Connecting to Office 2007 Access Database=== * If you don't have Office 2007 …')
 
imported>Scott
No edit summary
Line 36: Line 36:
table1Data = mydb.runquery('select * from "table1"')
table1Data = mydb.runquery('select * from "table1"')
table1Data =
table1Data =
     'id'    'filed01'
     'id'    'field01'
     [ 1]    'value1'
     [ 1]    'value1'
     [ 2]    'value2'
     [ 2]    'value2'

Revision as of 13:51, 24 January 2011

Examples use EVRI Database Object

NOTE: For PLS_Toolbox 6.1 and newer.

Connecting to Office 2007 Access Database

  • If you don't have Office 2007 or newer installed you'll need to download and install the newest Access database driver from here:

http://www.microsoft.com/downloads/en/details.aspx?familyid=7554f536-8c28-4598-9b72-ef94e038c891&displaylang=en

  • Make a database object with the appropriate 'location' and 'name':
>> mydb = evridb('type','access');
>> mydb.location = 'C:\Users\scott\Desktop';
>> mydb.dbname = 'test.accdb';
  • Test the connection, if you don't get a 1 back check the location and dbname:
>> mydb.testconnection
ans =
     1
  • Get a list of the tables in the database:
>> mytables = mydb.get_access_tables
mytables =
    '~TMPCLP877991'
    'table1'
    'table2'
    'table3'
  • Get a cell array of all the table data in "table1" with the first row containing column names:
>> mydb.use_column_names = 'yes';
>> mydb.return_type = 'cell';
table1Data = mydb.runquery('select * from "table1"')
table1Data =
    'id'    'field01'
    [ 1]    'value1'
    [ 2]    'value2'
    [ 3]    'value3'
    [ 4]    'value4'