Solved

how to connect to MS-Access DB

Posted on 2000-02-24
4
165 Views
Last Modified: 2010-04-04
I want to create a simple website that interfaces a small Access database with a Delphi program (CGI).  I'm using D5 Professional.

I've got the CGI stuff ok (I have D2 code that handles CGI i/o without using any CGI components).

What I need is to figure out how to send SQL queries to the Access database?!  I've created an ODBC alias for the .mdb file, but now what?!  DataSource, Database, and Table components are confusing me.  

As this is my first real database app, please give me step-by-step directions to open the database and run a query against some of the tables.

Thanks in advance :-)  I'll boost the points if it's harder than [I think] it should be.

Jon
0
Comment
Question by:jsexton
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 2555815
Hi
this is basic setup for access with odbc:

,i think you have half of it done already but i post all anyway:

Odbc:

1:   Open Control Panel, and then select ODBC DataSources (32bit) .
2:   When the Data Source Administrator appears, Click Add.
3:   find the one that says  Microsoft Access Driver (*.mdb)
     click it and click finish.
4:   A dialog will popup called ODBC Microsoft Access Setup
5:   in "data source name" edit box well call it "MyAccess"
6:   description well say is "tesing msaccess connection".
7:   click select and find your .mdb file click ok to select it.
8:   click "advanced" and make sure login name and password are blank.
9:   close advanced.
10:  close microsoft access setup dialog
11:  close the  Data Source Administrator.


in delphi:

1:  start or restart delphi if its already running.
2:  start a new project
3:  drop a ttable,tdbgrid,tdatasource,tdatabase on form.

    in object inspector:

4:  datasource1 dataset : table1
5:  dbgrid datasource   : datasource1
6:  database1 aliasname :
Alias_name_You_Made
7:  database1 databasename : MyAccessDB //type some name
8:  database1 loginprompt : false
9:  table1 databasename : MyAccessDB  //is now selectable
       {
        7:  database1 databasename : MyAccess
        8:  database1 loginprompt : false
        9:  table1 databasename : MyAccess
       }
10: table1 tablename : select a table
11: database1 connected : true
12: table1 active : true

and viola table should appear with no login prompt ,at least this method works for me everytime and i only discovered it today :-)
set loginprompt to true and you get the prompt or set to
false and get no prompt.

hope this helps someone somewhere

Regards Barry
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2555852
Hi,

It's very easy. First a few directions :

1. A table is the actual component which provides you the data.
2. A datasource is an in between component, to link a table with a data-aware component (eg DBGrid).

this very rudimentary explenation, I think articles are the best for you to understand delphi and access

eg.

general database

http://www.kaposnet.hu/books/tysdelphi4/ch18/ch18.htm

access and delphi

http://www.delphizine.com/features/1999/07/di199907bt_f/di199907bt_f.asp

http://www.wideman-one.com/gw/tech/Delphi/d3msa/D3MSA.html

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2555889
you could also have a look at other DelphiZine articles :

database programming part IV

http://www.delphizine.com/features/1999/02/di199902cj_f/di199902cj_d.asp

and all its precessors/successors (see article)

Zif.
0
 

Author Comment

by:jsexton
ID: 2559086
Barry, you're the man.  Zif, you are too - just a little slower ;-)

I followed your instructions and they worked perfectly.  Thanks!

Jon
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question