GWAcc Logo


TTextDSNCreator

Text DSN Creation Component

Most recent updates to this and other files can be found at:

http://www.gwacc.com/software.htm


What is it?
This component is used to Add, Reconfigure and Remove Text Datasource Names (DSNs) on the fly. Usually this is done via the ODBC32 control panel applet in any standard windows installation. It can be quite a complex task, given the nature of text files and some of the available extensions. We recommend using a file extension of '.csv' (where the fields in the file are comma separated) or '.tab' (tab delimited) on the files you'd like to use as database tables.

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

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 Text DSN, in a single movement. This will then allow you to treat that delimited text file as if it were a regular database file, opening it with your IDE table/SQL controls, executing SQL queries and so on.

We've just released an ActiveX version of the component which will allow you to add, configure and remove Text DSNs from your system using any other language/development environment that supports ActiveX controls. These include Borland Delphi, Visual Basic, Borland C++ Builder, Microsoft Visual C++ and many others. Demo programs for its use are included in the package.

The ActiveX control is completely standalone and doesn't require any dependancy files or Visual Basic runtime libraries.

Simply set a couple of properties, add ONE line of code to your application, and you can Add, Reconfigure and Remove Text 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

We highly recommend you use this documentation, together with the enclosed example in the file you downloaded, as well as the enclosed 'Using Text DSNs.chm' file (compressed HTML file).

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".

DatabaseFilePath : String
The fully qualified path to an existing Text file (if it exists). If it doesn't exist, the file must be created or placed in that directory before the DSN is used. 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\"

FileExtensions
The extensions used by the DSN. This will allow access to any file with an extension listed here. For some reason not all file extensions are supported, even though initial indications appear to be. This appears to be a Microsoft issue. We highly recommend using the standard MS ones, and change your file extensions to suit these (trust us on this one :)).

Example: 'csv,txt,tab' will allow access to any file with an extension of .csv, .txt or .tab

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

WorkingDirectory : String
Some ODBC Text databases require a working directory. This property allows you to set the path to this. Again, the control will NOT check to see if this directory exists first, since this may also need to be created on the fly. This can usually be left blank or set to the same directory as the DatabaseFilePath above.
Example "c:\testapplication\"

Password : String
Some ODBC 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 may be directly applicable to the DSN and operating system 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 Text DSN and looking under the advanced options for it. For those options that don't exist for this DSN type, you can safely ignore them, even if they appear in the property editor.

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.

Note: For unregistered users, if the DSN already exists, it will return 'False' and the DSN will not be updated. It will only return true and create the DSN if it did not already exist. Unregistered users will need to delete the DSN via the control panel ODBC32 applet before it can be recreated. This is not an issue for registered users or for those who have bought the source code.

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 TextDSN_Dxx.bpl file from the dialog box that pops up.
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 'TextDSNCreateUnit.pas' or 'TextDSNCreateUnit.dcu'.

Delphi 4 and Delphi 5
If you bought the source for the software, simply go to "File" | "Open" in Delphi and select the "TextDSN_DX.dpk" package. This was designed for Delphi 4, but will work fine in Delphi 5 as well. 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.

Delphi 6 and Delphi 7
This component has been completely revamped, so there's no more fiddling with DesignIntf and Proxies.pas, which will surely be a relief to a lot of people.

Remove all previous versions of the component and its BPL files from the Delphi packages list, and remove the BPL files from your PC.

If you have the registered (or unregistered) version of the component, do the following: Copy the runtime BPL file "TextDSN_DX(U).bpl" to someplace in your path, usually the windows system folder is a good place for this. X will be the version of Delphi you're working with (6 or 7). The letter "U" will only appear if you have the unregistered version (e.g. TextDSN_D6U.bpl). If you have the registered version it'll look like TextDSN_D6.bpl or TextDSN_D7.bpl.

Then, to install the component itself: In Delphi, go to the "Components" | "Install Packages" menu item, click on the "Add" button and select the "TextDSN_DXD(U).bpl" file (this is the designtime package, hence the second "D"). As before, X will be the version of Delphi (6 or 7).

If you purchased the source code (D6 and D7):
To install the packages in this case, simply use Delphi to open the TextDSN_DX.dpk file and compile it. You won't be able to install it, as this is the runtime library. THEN open the TextDSN_DXD.bpl (the design time package) and compile and install it. The TextDSN component will then appear on the 'GWACC' page of the component palette.

Remember 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 these files to your "Library Path" settings.

ActiveX installation
  1. Copy the TextDSNAX.ocx and TextDSNAX.lic files to a folder somewhere in your path (windows system folder recommended).
  2. Close your development environment
  3. Locate the program regsvr32.exe, (usually in your windows system folder as well). Drag and drop the TextDSNAX.ocx file onto regsvr32.exe.
  4. That's it, the ActiveX control is now registered with the system.
  5. For further details on integrating it with your development environment, consult your environment's documentation.

To uninstall the ActiveX do the following:

  1. Execute the following command from a DOS prompt: <path to regsvr32.exe>
    regsvr32 -U <path to ActiveX>TextDSNAX.ocx.
  2. This will deregister the OCX from your system.
  3. Delete the TextDSNAX.ocx and TextDSNAX.lic files from your PC

Redistribution
Please be aware that you may need to redistribute the "TextDSN_DX.bpl" package if you compile your project with the option to use runtime packages turned on. This file will need to be copied to the client's Windows System folder (usually "c:\windows\system").

Users of the ActiveX version will need to distribute the TextDSNAX.ocx with their application. Please not NOT distribute the TextDSNAX.lic file along with it, as this is only used in the design time environment and does not affec the actual running of the program.

History of changes

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. You are entitled to free upgrades of that license type as they become available.

How to register
Visit http://www.gwacc.com/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 or source code versions of this software to anyone, except with the express, written permission of GWAcc Limited.

 

back to top...