delphidelphi-7adoconnection

ConnectionString in Delphi?


I'm trying to set the ConnectionString for a ADOConnection on start. Currently I'm using this code:

ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\x.mdb;Persist Security Info=False;';

Only problem is, I get a "EOLeException with message 'Authentication Failed' when I compile (as well as Access Violation). I'm sure it can't be that difficult, since the connection string is copied straight out of the object inspector (which works perfect when entered normally in object inspector.). My code currently resides on FormCreate.

Any help would be appreciated!


Solution

  • Well, if your ADOConnection is in a datamodule along with your other dataset components, you will see an Access Violation on connect if the MainForm is created before your datamodule.

    This maybe not be the problem but it's easy to check.

    To resolve go to the menu Project|Options and select 'Form' in the list. The 'Auto-create Forms' listbox gives the forms created on program load, and the order in which they are created. Select the datamodule entry and drag it to the top of the list.

    Good luck.