Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access DSN less connection.

Status
Not open for further replies.

ashkar

Programmer
Mar 28, 2001
6
0
0
CL
Hi,

I've never worked with DBs in Deplhi before so I'm kind of lost. Is there a way to connect to a Access 97 DB without using a DSN? A little example perhaps? :)

Thanks,

Ashkar
 
First you have to make an alias in the BDE(Borland Database Engine) Administrator pointing to your acces database

Put on the Form in Delphi a Ttable, TdataSource, a TDB navigator and some DBEDits .

You also can use the database wizard to generate an example. S. van Els
SAvanEls@cq-link.sr
 
Hmm... Thanks :), but unfortunately that doesn't solve my problem.
In the end, what I need to do is some way to connect to access DB without having to set anything outside my program. I'm writing a CGI program that will reside in a NT server that I don't admin, so I need to connect to the DB without setting DSN or BDE aliases.Of course this can be done in Delphi, but I don't know if theres a simple way to do it.
Anyway, in the meanwhile I arrived to a simple and ugly solution: From my program, I call some ASP scripts to do my DB work, while I do whith delphi what I can't do with ASP.

Thanks,

Ashkar
 
Hi Ashkar,
All u want to do can be done using Session Variable or using Session Component from "Data Access" Page, which is available whenever you user DBTables unit in your unit uses clause.
below is simple piece of code which can be used to first check if BDE alias exists, if not then create new BDE alias
for Access DataBase.

//Code
if not Session.IsAlias('MyAlias') then
begin
try
DriverList := TStringList.Create;
DriverList.Add('DATABASE NAME= DRIVE:/PATH/DATABASE.MDB');
DriverList.Add('USER NAME = UserName');
Session.AddAlias('MyAlias','MSACCESS',DriverList);
finally
DriverList.Free;
end;
end;

and define DriverList as
var
DriverList : TStrings;


Hope it will help you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top