Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create an ODBC datasource for an Access database Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Create an ODBC datasource for an Access database 30-Aug-03
Category
Database Others
Language
Delphi 2.x
Views
138
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler 

How to create an ODBC datasource for an Access database 

Answer:

1   unit odbcsetup;
2   {Written By Aaron Miles 2002
3   Creates ODBC for Access Database}
4   
5   interface
6   
7   uses
8     sysutils, windows;
9   
10  procedure CreateDSN(Name, Database: string);
11  procedure RemoveDSN(Name: string);
12  
13  implementation
14  
15  const
16    ODBC_ADD_DSN = 1; {Add data source}
17    ODBC_CONFIG_DSN = 2; {Configure (edit) data}
18    ODBC_REMOVE_DSN = 3; {Remove data source}
19    ODBC_ADD_SYS_DSN = 4; {Add a system DSN}
20    ODBC_CONFIG_SYS_DSN = 5; {Configure a system DSN}
21    ODBC_REMOVE_SYS_DSN = 6; {Remove a system DSN}
22    ODBC_REMOVE_DEFAULT_DSN = 7; {Remove the default DSN}
23  
24  function SQLConfigDataSource(hwndParent: HWND; fRequest: WORD; lpszDriver: LPCSTR;
25    lpszAttributes: LPCSTR): BOOL; stdcall; external 'ODBCCP32.DLL';
26  
27  procedure CreateDSN(Name, Database: string);
28  begin
29    SQLConfigDataSource(0, ODBC_ADD_DSN, 'Microsoft Access Driver (*.mdb)', 
30  PChar('DSN =
31      '+ #0 + ' Driver = ODBCJT32.DLL '#0 + ' DBQ = '+Database+ #0 +
32      'DefaultDir=' + ExtractFilePath(Database) + #0 + 'Description=Auto Setup
33      Aaron Miles 'ccess '#0 + ' UID = Admin'#0));
34  end;
35  
36  procedure RemoveDSN(Name: string);
37  begin
38    SQLConfigDataSource(0, ODBC_REMOVE_DSN, '
39      PChar('DSN=' + Name + #0));
40  end;
41  
42  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC