Solved

how to connect to MS-Access DB

Posted on 2000-02-24
4
161 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now