trouble creating DSN
- From: "Keith G Hicks" <krh@xxxxxxxxxxx>
- Date: Fri, 17 Nov 2006 17:57:49 -0500
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.
.
- Follow-Ups:
- Re: trouble creating DSN
- From: Keith G Hicks
- Re: trouble creating DSN
- Prev by Date: Re: Transaction Problem, part two..
- Next by Date: Re: Transaction Problem, part two..
- Previous by thread: Transaction Problem, part two..
- Next by thread: Re: trouble creating DSN
- Index(es):
Relevant Pages
|