?
Solved

how to connect to MS-Access DB

Posted on 2000-02-24
4
Medium Priority
?
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 200 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 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