Programmatically registering a user DSN

Posted on 2000-03-28
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?
Question by:JLANE
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

saravananr earned 100 total points
ID: 3098414
unit Unit1;


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


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

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

  Form1: TForm1;


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

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
  rc: Integer;
  sName, sMDB : string;
    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.');



Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

623 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