GWAcc Logo


TAccessDSNCreator

Microsoft Access DSN Creation Component


What is it?
This component is used to Add, Reconfigure and Remove MS Access Datasource Names (DSNs) on the fly. Usually this is done via the ODBC32 control panel applet in any standard windows installation.

Why use it?
Ever needed to create a Microsoft Access Datasource Name (DSN) on the fly from inside your Delphi code? We certainly have! This incredibly useful little Delphi component allows you to create, modify and delete DSNs at runtime from a Delphi application (32 bit only).

Why would you want to do this? Quite often we (as developers at GWAcc) find ourselves having to climb into the control panel and muck around inside the ODBC32 applet. It gets annoying, especially if you have to do it several times in a row, even more so when it means having to switch between changing user names, passwords, paths, exclusivity... you get the idea!

This control allows you to add or change all the properties of a Microsoft Access DSN, in a single movement.

Simply set a couple of properties, add ONE line of code to your application, and you can Add, Reconfigure and Remove MS Access DSNs in a flash!

An example application has been included with the component, that you can use to check the assignment of properties and invocation of methods.


Properties

About : Displays an 'About' box, with your registered status and our contact details

Action : TDSNExecuteAction
The action to perform when the Execute method is invoked. The action can consist of the following values:

DSNNameOrAlias : String
The name for the DSN as it will appear in the drop down list of aliases available to the development environment. This is the internal name used by the ODBC drivers. No spaces to occur in this string. The component will accept them, but then if you try to modify the DSN via the control panel, it might get upset with you. Example: "TstDSN"

DSNUserDescription : String
The name that you will refer to it by, kind of like a comment string. After all "My Test DSN" is a lot more meaningful than "TstDSN".

DatabaseFile : String
The fully qualified path to an existing MS Access database file (if it exists). The control does NOT check to see if the file already exists, since you may want to create the database on the fly as well, either prior to or subsequent to using this control.
Example "c:\testapplication\test.mdb"

UserID : String
Some MS Access databases require a login and a password to be able to open them. This is the login name.
Example: "JoeSoap"

WorkGroupFile : String
Some MS Access databases require a workgroup file used to control user access, table locking and so on based on the user. This property allows you to set the path to this. Again, the control will NOT check to see if this file exists first, since this may also need to be created on the fly.
Example "c:\testapplication\test.mdw"

WorkingDir : String
Sometimes a working directory also needs to be specified. If left blank, the control will automatically set it to the directory of the DatabaseFile property. Again, no path checking takes place.
Example "c:\testapplication\" or "c:\testapplication" (the trailing backslash doesn't matter)

Password : String
Some MS Access databases require a login and a password to be able to open them. This is the password that must be supplied if necessary
Example: "TestPass"

The following extended options are directly applicable to the DSN type and affect how the ODBC32 drivers will handle your databases. You can check these values by opening control panel, running the ODBC32 applet, double clicking any MS Access DSN and looking under the advanced options for it.

optExtendedAnsiSQL : Integer
optImplitCommitSync : String
optMaxBufferSize : Longint (MUST be a multiple of 512)
optMaxScanRows : Longint
optPageTimeout : Longint
optDSNReadOnly : Boolean
optExclusive : Boolean
optSafeTransactions : Longint
optThreads : Longint
optUserCommitSync : Boolean

back to top...

Methods:
This component only has one method.

back to top...

Execute : Boolean
This method triggers the action you defined by the Action property above. Some of the properties may not actually need to be used, for example with the REMOVE_DSN action, only the DSNNameOrAlias needs to be supplied. The action is synchronous, and the function will return only after it has attempted the action you requested.
Returns: True = Your action succeeded, False = Your action failed (for example trying to remove a nonexistent DSN.

Events
This component triggers no events

back to top...


Installation
Unzip the package you downloaded.
In Delphi, go to "Components" | "Install Packages" menu item, click on the "Add" button and select MSAccessDSN_Dxx.bpl file from.
A new page will appear on the component palette (GWACC) with the component(s) on it. In order to compile and run the included example application, as well as any other application you create using this component, you will also need to add the path to the .dcu files to your environment search path.

Do this in Delphi by going to "Tools" | "Environment Options" | "Library" and adding the path to the "Library Path" settings. If don't add the path to the Delphi Library Search Path, you'll get an error when compiling an application that the compiler can not find 'AccessDSNCreateUnit.pas' or 'AccessDSNCreateUnit.dcu'.

If you bought the source for the software, simply go to "File" | "Open" in Delphi and select the "MSAccessDSN_DX.dpk" package. This was designed for Delphi 4, but will work fine in Delphi 5 and should work for other versions such as Delphi 6, and Borland C++Builder too. In this case it will ask you if you want to upgrade the package to the new format. Answer "Yes", and then click on the "Compile" button. After this is complete, click on the the "Install" button to install the component on the GWACC page (default) or on the page you selected. See above about adding the path to the units to the Delphi library search path if you get any errors during compilation.

If you downloaded the shareware trial release, the file will be called MSAccessDSN_DxU.bpl where 'x' corresponds to the delphi version you are using. The registered version will simply be named MSAccessDSN_Dx.bpl. You will also need to add the path to the .dcu files to your environment search path. Do this in Delphi by going to "Tools" | "Environment Options" | "Library" and adding the path to the "Library Path" settings.

History of changes
July 20, 2001. 1.0.0.2 First public release.

Future plans:
Apart from any possible bug fixes, there are no major changes planned for this component

Known bugs
There are no known bugs at this time. If you find some bugs, please report them to gwacc@kagi.com. The support email address gwacc@kagi.com is available for all your comments, questions and ideas. If you'd like to see some additional functionality in this component, please let us know!

Benefits of registration
By registering one or more licenses, you have the right to incorporate this component into as many applications as you like, royalty-free. If you decide to purchase the license for this, or any other GWAcc component, you will get one year of free upgrades. New versions of components will be available to you at significantly lower price after the period of one year (during which you get all new versions for free).

How to register
Visit http://www.gwacc.co.za/software.htm and register online. All major credit cards apply through secure Internet protocol. You can also register via fax, international mail order, bank wire or US Check.

License :
Please read carefully EULA_license.txt file before using this software.

In addition to this, GWAcc grants you the license to distribute the shareware version ONLY of this component, however you see fit, as long as ALL the files are kept together in one archive. We will not levy any charges for your distributing of the shareware components in any format, electronic or otherwise.

You may NOT redistribute the registered versions of this software to anyone, except with the express, written permission of G. Wilson & Associates.

back to top...