trouble creating DSN



When I leave off the UID and PWD lines for sAttribs, when this runs, it pops
up the DSN settings window and lets me fill in the rest. But with the UID
and PWD below, nothing happens. The code runs without any errors but no DSN
is created. I've scoured the web and can't find anything to indicate that
I'm doing anything wrong here. Any suggetions (using sql 2k and D7)?

interface
....
const
ODBC_ADD_DSN = 1; // Add data source
ODBC_CONFIG_DSN = 2; // Configure (edit) data
ODBC_REMOVE_DSN = 3; // Remove data source
ODBC_ADD_SYS_DSN = 4; // add a system DSN
ODBC_CONFIG_SYS_DSN = 5; // Configure a system DSN
ODBC_REMOVE_SYS_DSN = 6; // remove a system DSN
ODBC_REMOVE_DEFAULT_DSN = 7; // remove the default DSN

function SQLConfigDataSource(hwndParent: HWND; fRequest: WORD; lpszDriver:
LPCSTR;
lpszAttributes: LPCSTR): BOOL; stdcall; external 'ODBCCP32.DLL';

....
....
....

implementation

procedure TForm1.CreateDSN;
var
sDriver, sAttribs: string;
begin

sDriver := 'SQL Server';
sAttribs := 'DSN=Keith DSN Test' + #0;
sAttribs := sAttribs + 'DESCRIPTION=Keith DSN Test description' + #0;
sAttribs := sAttribs + 'SERVER=ServerX' + #0;
sAttribs := sAttribs + 'DATABASE=Northwind' + #0;
sAttribs := sAttribs + 'UID=sa' + #0;
sAttribs := sAttribs + 'PWD=abc123' + #0;

try

SQLConfigDataSource
(
Self.Handle,
ODBC_ADD_SYS_DSN,
PChar(sDriver),
PChar(sAttribs)
);
except
ShowMessage('Error creating DSN');
end;

end;

end.



.



Relevant Pages

  • Re: caching problem
    ... >I am new to asp.net I coded simple login form and placed two textboxes and ... I want to verify the uid and pwd in my databasewith the user ... You'll have to edit, compile, and then refresh the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Retrieve attributes from Active Directory
    ... feed.When user enters his uid and pwd, i will then compare it with Active ... store these uid & pwd session variables and use it to connect to ... How do you compare uid & pwd with AD.. ... Now I have to synchronize the Active Directory users database with the ...
    (microsoft.public.windows.server.scripting)
  • caching problem
    ... I want to verify the uid and pwd in my databasewith the user ... when i run the page from IE it is not updating the modified code. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SQLSTRINGCONNECT und dann?
    ... pwd peer hand hinzugefuegt aber trotzdem geht es nicht. ... Nur DRIVER, SYSTEM, UID, PWD ist erforderlich. ... oder braucht vielleicht Foxpro irgendwas? ...
    (microsoft.public.de.fox)
  • Anllegen eines DSN funktioniert nur Ohne UID und PWD... warum?
    ... Allerinds funktioniert es nur wenn ich den odbc pfad ohne UID und PWD anlege. ... Im Code ist Uid und pwd auskommentiert so funktioniert der Code. ...
    (microsoft.public.de.sqlserver)