Mega Code Archive

 
Categories / Delphi / Strings
 

What is the procedure for connecting delphi to an ms access database

David Zaret <zaretd@il.us.swissbank.com> posted: Here is the step-by-step process that I took to connect my Delphi app. to an Access database: Open up the Windows Control Panel. Open up the ODBC "Data Sources" icon. ADD a new Data Source of Type ACCESS DATA. Provide a unique "Data Source Name" (it doesn't really matter what you call it - description is optional). Choose the Database File by clicking the "Select Database" button. Close the "Data Source" window. Open up the "Database Engine Configuration" to get to the "BDE Configuration Utility" screen. Click on the "NEW ODBC Driver" button. Provide a "SQL Link Driver" - once again, it doesn't really matter what you call it. Select a Default ADBC Driver of type ACCESS DATA. Under "Default Data Source Name" choose the name of the ADBC driver that you provided from the Control Panel. Create a new alias by clicking on the "Alis" page tab. Click on the "New Alias" button. Give the alias a name. Select an Alias Type of ODBC_[WHATEVER YOU CALLED IT IN STEP 11]. Save your settings with File/Save. You can now close the BDE Config. Utility. IN YOUR PROJECT --- (I am sure that there are many ways to approach the next steps, but here's what I did) a) Add a Tdatabase component 1) Set the AliasName to the new alias that you just defined. 2) Provide a dummy DatabaseName. 3) Set the LoginPrompt to FALSE (if you don't want permission checking). b) Add a TQuery component. 1) Set the DatabaseName to the dummy name you provided in a.2) c) Add a TDataSource component. 1) Set the DataSet to the name of the TQuery comp. And you are done! You now have a SQL-ready, data-aware fomr that y ou can plop SQL into and data-aware components on to!