Difference between revisions of "Microsoft Access OLE DB"

From database24
Jump to navigation Jump to search
(Created page with '== General == It is possible to access some resources without writing any line of code. All you need is to write a query which makes use of ISAM OLEDB. For further reading: * [h...')
 
Line 7: Line 7:
  
 
== Microsoft Access ==
 
== Microsoft Access ==
 +
 +
=== Tables and Queries ===
 
<syntaxhighlight lang=vb>
 
<syntaxhighlight lang=vb>
 
SELECT *
 
SELECT *
Line 12: Line 14:
 
     IN 'c:\data.mdb'
 
     IN 'c:\data.mdb'
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
This allows you to easily refer to other databases' tables and queries without the need to create a linked table.
  
 
== Microsoft Excel ==
 
== Microsoft Excel ==
  
=== Worksheet ===
+
=== Named Range ===
 
<syntaxhighlight lang=vb>
 
<syntaxhighlight lang=vb>
 
SELECT *
 
SELECT *
   FROM [Worksheet$]  
+
   FROM [NamedRange]  
 
     IN 'c:\data.xls'[EXCEL 8.0;];
 
     IN 'c:\data.xls'[EXCEL 8.0;];
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Named Range ===
+
Accessing data by naming ranges allows the developer to specify exactly what should be imported. By this&mdash;and the optional parameters&mdash;it should be easy to retrieve exactly the desired data and nothing else.
 +
 
 +
=== Worksheet ===
 
<syntaxhighlight lang=vb>
 
<syntaxhighlight lang=vb>
 
SELECT *
 
SELECT *
   FROM [NamedRange]  
+
   FROM [Worksheet$]  
 
     IN 'c:\data.xls'[EXCEL 8.0;];
 
     IN 'c:\data.xls'[EXCEL 8.0;];
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 37: Line 43:
  
 
=== Optional Parameters ===
 
=== Optional Parameters ===
* HDR = yes|no
+
* HDR
* IMEX = 0|1
+
* IMEX
  
 
== Text file ==
 
== Text file ==
Line 48: Line 54:
  
 
=== Optional Parameters ===
 
=== Optional Parameters ===
* HDR = yes|no
+
* HDR
 +
 
 +
== Optional Parameters ==
 +
* HDR
 +
** Does the data source have headings?
 +
** yes|no
 +
** Default: yes
 +
 
 +
* IMEX
 +
** Should the data be imported "as is" in text format or should windows try to guess the value type of each column?
 +
** 0|1
 +
** Default: 1 (guess)

Revision as of 14:49, 26 August 2010

General

It is possible to access some resources without writing any line of code. All you need is to write a query which makes use of ISAM OLEDB.

For further reading:

Microsoft Access

Tables and Queries

SELECT *
  FROM tblTable 
    IN 'c:\data.mdb'

This allows you to easily refer to other databases' tables and queries without the need to create a linked table.

Microsoft Excel

Named Range

SELECT *
  FROM [NamedRange] 
    IN 'c:\data.xls'[EXCEL 8.0;];

Accessing data by naming ranges allows the developer to specify exactly what should be imported. By this—and the optional parameters—it should be easy to retrieve exactly the desired data and nothing else.

Worksheet

SELECT *
  FROM [Worksheet$] 
    IN 'c:\data.xls'[EXCEL 8.0;];

Reference

SELECT *
  FROM [Worksheet$A1:B2] 
    IN 'c:\data.xls'[EXCEL 8.0;];

Optional Parameters

  • HDR
  • IMEX

Text file

SELECT *
  FROM data.csv 
    IN 'c:\'[TEXT;];

Optional Parameters

  • HDR

Optional Parameters

  • HDR
    • Does the data source have headings?
    • yes|no
    • Default: yes
  • IMEX
    • Should the data be imported "as is" in text format or should windows try to guess the value type of each column?
    • 0|1
    • Default: 1 (guess)