[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to connect to MS-Access DB

Posted on 2000-02-24
4
Medium Priority
?
176 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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