Programmatically create DSN usind SQL Server Authentication
From: Willem Semmelink via SQLMonster.com (forum_at_SQLMonster.com)
Date: 02/02/05
- Next message: OrSomeThingLikeThat: "RE: Access-SQL Serv Autonumber"
- Previous message: JohnD: "Datetime field overflow error"
- Next in thread: Sue Hoegemeier: "Re: Programmatically create DSN usind SQL Server Authentication"
- Reply: Sue Hoegemeier: "Re: Programmatically create DSN usind SQL Server Authentication"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 02 Feb 2005 12:48:34 GMT
Hi
I am trying to programmatically create a DSN on a target system for SQL
Server using SQL Server Authentication.
There are documented solutions for using Windows authentication, but the
SQL Server authentication evades me.
1. Hard-coding in the registry:
Microsoft illustrates this in
HOWTO: Programmatically Create a DSN for SQL Server with VB
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q184608
KHLM/SOFTWARE/ODBC/ODBC.INI/<dsn-name> allows me to set LastUser, but I
have not found a way to specify the user's password in the registry (if at
all possible).
2. Windows API:
Microsoft's document HOWTO: Create and Remove a DSN in Visual Basic
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q171146
is off-topic for my purpose because it only shows Windows authentication.
ODBCCP32.DLL has a function SQLConfigDataSource, and that works fine,
provided that Windows Authentication is used. It does not work for SQL
Server Authentication, as documented in
http://www.sqlmonster.com/Uwe/Forum.aspx/sql-server-odbc/1335/Problems-
setting-DSN-from-csharp-when
3. It looks like odbcconf.exe might be a possibility, with something like
odbcconf /A {CONFIGDSN "SQL Server"}
but I could not yet get it working. and I cannot find documentation or a
good working example. Adding SQL Server attributes just result in the
message "DSN Attributes are missing"
odbcconf /A {CONFIGDSN "SQL Server|DSN=Test|DATABASE=pubs|UID=nnn|PWD=xxx"}
4. I cannot use the RegisterDatabase function in VB as documented in
HOWTO: Set Up ODBC Data Sources When Distributing Apps
http://support.microsoft.com/default.aspx?scid=kb;EN-US;123008
I need a solution I can implement in C#, C++ and Installshield's
Installscript. This solution also documents only Windows authentication.
5. Letting the user configure this manually, e.g. by starting the control
panel applet, is not an option. Using DSN-less connection options is also
out.
Can anyone tell me whether it is at all possible to programmatically create
a DSN for SQL Server, using SQL Server Authentication, and how I can
specify the UID and PWD for the user?
Thanks
Willem Semmelink
-- Message posted via http://www.sqlmonster.com
- Next message: OrSomeThingLikeThat: "RE: Access-SQL Serv Autonumber"
- Previous message: JohnD: "Datetime field overflow error"
- Next in thread: Sue Hoegemeier: "Re: Programmatically create DSN usind SQL Server Authentication"
- Reply: Sue Hoegemeier: "Re: Programmatically create DSN usind SQL Server Authentication"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|