Solved

Programmatically registering a user DSN

Posted on 2000-03-28
1
797 Views
Last Modified: 2012-05-04

I know that this question has probably been asked fumfty times before but...

How do I get a listing of my currently installed DSNs and User DSNs, and then how do I create a DSN?

I tried using SOFTWING odbctool.dll (I used regsvr32 odbctool.dll) but delphi didn't recognize any of the classes. If it had worked, it would have been exactly what I was looking for.

Can anybody help me?
0
Comment
Question by:JLANE
[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
1 Comment
 

Accepted Solution

by:
saravananr earned 100 total points
ID: 3098414
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons;

const
  ODBCCP32 = 'ODBCCP32.DLL';

  function SQLConfigDataSource(
               hwndParent:       Integer;
               fRequest:         Integer;
               lpszDriverString: String;
               lpszAttributes:   String): Integer;stdcall;



type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  Form1: TForm1;

implementation

  function SQLConfigDataSource(
               hwndParent:       Integer;
               fRequest:         Integer;
               lpszDriverString: String;
               lpszAttributes:   String): Integer; external ODBCCP32 Name 'SQLConfigDataSource';

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  rc: Integer;
  sName, sMDB : string;
begin
    sName := 'LqODBCDsn11';
    sMDB := 'D:\PROJECTS\LQ\Speedline\InterFace Database\Data\intfacedb.db';//   ' ( app.path & "test.mdb")

{   Microsoft Access Driver (*.mdb)}
//    rc := SQLConfigDataSource(0, 1, 'Microsoft Access Driver (*.mdb)', 'DSN=' + sName +
//    Chr(0) + 'DBQ=' + sMDB + Chr(0) + Chr(0));


// return code 0 means failure
    If rc = 0 Then
        ShowMessage('Could not configure data Source.');

end;

end.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 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