root/trunk/activex/vbscript_accesstodbase.d

Revision 28, 1.5 kB (checked in by jcc7, 3 years ago)

Improved ActiveX helper code and found some new things to do with it (as shown by the examples). I still need to go back and remove specific references to directories on the computer I was working on though. Also, not all of the examples work fully.

Line 
1 import std.c.windows.windows; /* for MessageBoxA */
2
3 import activex; /* for AXO */
4
5 void main()
6 {
7     AXO cnn = new AXO("ADODB.Connection");
8     AXO rst = new AXO("ADODB.Recordset");
9
10
11     //Const adSchemaProviderSpecific = -1
12
13     //Const JET_SCHEMA_USERROSTER = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
14
15    
16
17     //Working formats:
18     //dBase 5.0  - directory has to already exist
19     //dBase IV   - directory has to already exist
20     //Jet 3.x    - .mdb file has to already exist (and be the right format)
21
22     //Doesn't work:
23     //Excel 8.0
24     //Text        - something is read-only?
25     //Lotus WK4
26     //HTML Export - something is read-only?
27     //HMTL Import - The Microsoft ... cannot open the file 'F:\Pgm\ADO\Paradox'. ...
28
29
30     char[] F = r"D:\MyFiles\pgm\d\src\jcc7\tests\activex\filenames.mdb";
31     char[] Format = "dBase IV";
32     char[] TargetPath = r"d:\MyFiles\pgm\d\src\jcc7\tests\activex";
33     char[] databaseTarget = "dbase";
34     char[] Table = "tbl_turnpike_filenames";
35
36     try
37     {
38         with(cnn)
39         {
40             set("ConnectionString", toVariant("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" ~ F ~ "'" ));
41             call("Open");
42         }
43
44         rst.call("Open",
45           toVariant("SELECT * INTO [" ~ Format ~ "; database=" ~ TargetPath ~ "].[" ~ databaseTarget ~ "] FROM [" ~ Table ~ "]"),
46           toVariant(cnn),
47           toVariant(3), /* Const adOpenStatic = 3 */
48           toVariant(1)); /* Const adLockReadOnly = 1 */
49
50     }
51     finally
52     {
53         int ret = MessageBoxA(null, "Message\0", "Title\0", 0);
54         //ie.call("Quit");
55     }
56 }
Note: See TracBrowser for help on using the browser.